Skip to content

Commit 89a1725

Browse files
ondrejmirtesstaabm
authored andcommitted
Make strtolower()/strtoupper() frameless
Both are single-argument wrappers around zend_string_tolower/upper; static analyzers and general string handling call them at very high frequency. The frameless call convention removes the call frame setup and argument copying. Co-authored-by: Markus Staab <maggus.staab@googlemail.com> Closes GH-23084
1 parent e36a123 commit 89a1725

4 files changed

Lines changed: 53 additions & 9 deletions

File tree

ext/standard/basic_functions.stub.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,10 +2368,16 @@ function join(string|array $separator, ?array $array = null): string {}
23682368
*/
23692369
function strtok(string $string, ?string $token = null): string|false {}
23702370

2371-
/** @compile-time-eval */
2371+
/**
2372+
* @compile-time-eval
2373+
* @frameless-function {"arity": 1}
2374+
*/
23722375
function strtoupper(string $string): string {}
23732376

2374-
/** @compile-time-eval */
2377+
/**
2378+
* @compile-time-eval
2379+
* @frameless-function {"arity": 1}
2380+
*/
23752381
function strtolower(string $string): string {}
23762382

23772383
function str_increment(string $string): string {}

ext/standard/basic_functions_arginfo.h

Lines changed: 15 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/basic_functions_decl.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/string.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,19 @@ PHP_FUNCTION(strtoupper)
11921192
}
11931193
/* }}} */
11941194

1195+
ZEND_FRAMELESS_FUNCTION(strtoupper, 1)
1196+
{
1197+
zval str_tmp;
1198+
zend_string *str;
1199+
1200+
Z_FLF_PARAM_STR(1, str, str_tmp);
1201+
1202+
RETVAL_STR(zend_string_toupper(str));
1203+
1204+
flf_clean:
1205+
Z_FLF_PARAM_FREE_STR(1, str_tmp);
1206+
}
1207+
11951208
/* {{{ Makes a string lowercase */
11961209
PHP_FUNCTION(strtolower)
11971210
{
@@ -1205,6 +1218,19 @@ PHP_FUNCTION(strtolower)
12051218
}
12061219
/* }}} */
12071220

1221+
ZEND_FRAMELESS_FUNCTION(strtolower, 1)
1222+
{
1223+
zval str_tmp;
1224+
zend_string *str;
1225+
1226+
Z_FLF_PARAM_STR(1, str, str_tmp);
1227+
1228+
RETVAL_STR(zend_string_tolower(str));
1229+
1230+
flf_clean:
1231+
Z_FLF_PARAM_FREE_STR(1, str_tmp);
1232+
}
1233+
12081234
PHP_FUNCTION(str_increment)
12091235
{
12101236
zend_string *str;

0 commit comments

Comments
 (0)