Skip to content

Commit ff6b4ad

Browse files
committed
FAST ZPP for strtok() and nl2br()
Looking at some template-driven code that calls these hundreds of times per request
1 parent f487e4c commit ff6b4ad

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ext/standard/string.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,9 +1287,17 @@ PHP_FUNCTION(strtok)
12871287
char *pe;
12881288
size_t skipped = 0;
12891289

1290+
#ifndef FAST_ZPP
12901291
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|S", &str, &tok) == FAILURE) {
12911292
return;
12921293
}
1294+
#else
1295+
ZEND_PARSE_PARAMETERS_START(1, 2)
1296+
Z_PARAM_STR(str)
1297+
Z_PARAM_OPTIONAL
1298+
Z_PARAM_STR(tok)
1299+
ZEND_PARSE_PARAMETERS_END();
1300+
#endif
12931301

12941302
if (ZEND_NUM_ARGS() == 1) {
12951303
tok = str;
@@ -4322,9 +4330,17 @@ PHP_FUNCTION(nl2br)
43224330
zend_bool is_xhtml = 1;
43234331
zend_string *result;
43244332

4333+
#ifndef FAST_ZPP
43254334
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &str, &is_xhtml) == FAILURE) {
43264335
return;
43274336
}
4337+
#else
4338+
ZEND_PARSE_PARAMETERS_START(1, 2)
4339+
Z_PARAM_STR(str)
4340+
Z_PARAM_OPTIONAL
4341+
Z_PARAM_BOOL(is_xhtml)
4342+
ZEND_PARSE_PARAMETERS_END();
4343+
#endif
43284344

43294345
tmp = str->val;
43304346
end = str->val + str->len;

0 commit comments

Comments
 (0)