sveneld commented on code in PR #3109: URL: https://github.com/apache/thrift/pull/3109#discussion_r1997668235
########## lib/php/lib/Transport/TSocket.php: ########## @@ -218,7 +218,7 @@ public function open() throw new TTransportException('Cannot open null host', TTransportException::NOT_OPEN); } - if ($this->port_ <= 0) { + if ($this->port_ <= 0 && substr($this->host_, 0, strlen('unix://')) !== 'unix://') { Review Comment: Thank you for updating a unit test. I don't agree with using substr instead of using one function you offer to use two substr and strlen, and even if remove strlen and relace it with const value it will be less efficient just run this code for compare, the most productive will be strpos https://3v4l.org/rv7pl ``` <?php $host = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; //$host = 'unix://unixhost'; $start = microtime(true); for ($i=0; $i<=1000; $i++) { substr($host, 0, strlen('unix://')) !== 'unix://'; } echo (microtime(true) - $start) . PHP_EOL; $start = microtime(true); for ($i=0; $i<=1000; $i++) { strpos($host, 'unix://') !== 0; } echo (microtime(true) - $start) . PHP_EOL; $start = microtime(true); for ($i=0; $i<=1000; $i++) { preg_match('~^unix://~', $host); } echo (microtime(true) - $start) . PHP_EOL; ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@thrift.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org