Basic string comparison functions still use old parameter parsing API

php.internals

Benjamin Coutu

9 years ago
Hi Dmitry, I just noticed that all basic string comparison functions in Zend/zend_builtin_functions.c, especially "strcmp", "strncmp", "strcasecmp", "strncasecmp" still use the old and inefficient parameter parsing API, unlike similar functions in ext/standard/string.c such as "substr_compare", "strtok", "str(i)str", "str(i)pos", "strr(i)pos", "strrchr" that already consistently use the new efficient macro-based API. I think one can consider "str(n)cmp" and "str(n)casecmp", etc. at least as important as "substr_compare", especially considering that these are wrappers around very basic functions that often get called in very hot code or inside tight loops (e.g. sorting). I therefore recommend changing those 4 functions in Zend/zend_builtin_functions.c to use ZEND_PARSE_PARAMETERS_* macros for PHP 7.2. What do you think? -- Benjamin Coutu ZeyOS, Inc.

Fleshgrinder

9 years ago
On 6/7/2017 7:15 PM, Benjamin Coutu wrote:
> Hi Dmitry, > > I just noticed that all basic string comparison functions in > Zend/zend_builtin_functions.c, especially "strcmp", "strncmp", > "strcasecmp", "strncasecmp" still use the old and inefficient > parameter parsing API, unlike similar functions in > ext/standard/string.c such as "substr_compare", "strtok", > "str(i)str", "str(i)pos", "strr(i)pos", "strrchr" that already > consistently use the new efficient macro-based API. > > I think one can consider "str(n)cmp" and "str(n)casecmp", etc. at > least as important as "substr_compare", especially considering that > these are wrappers around very basic functions that often get called > in very hot code or inside tight loops (e.g. sorting). I therefore > recommend changing those 4 functions in Zend/zend_builtin_functions.c > to use ZEND_PARSE_PARAMETERS_* macros for PHP 7.2. > > What do you think? >
Help? :) https://github.com/php/php-src/pull/2565
-- Richard "Fleshgrinder" Fussenegger