Skip to content

Commit 98e5128

Browse files
committed
opcache optimizer: optimize some more functions on compile time
- don't optimize basename(), version_compare(string, string, string) - optimize strtolower(string), strtoupper()
1 parent f1e43b7 commit 98e5128

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ext/opcache/Optimizer/sccp.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ static inline int ct_eval_func_call(
872872
} ZEND_HASH_FOREACH_END();
873873
/* pass */
874874
} else if (zend_string_equals_literal(name, "implode")
875-
|| zend_string_equals_literal(name, "array_unique")) {
875+
|| zend_string_equals_literal(name, "array_unique")) {
876876
zval *entry;
877877

878878
if (Z_TYPE_P(args[0]) != IS_ARRAY) {
@@ -916,6 +916,11 @@ static inline int ct_eval_func_call(
916916
|| (Z_TYPE_P(args[1]) != IS_LONG)) {
917917
return FAILURE;
918918
}
919+
if (Z_LVAL_P(args[1]) < 1) {
920+
// levels must be >= 1, else we get a ValueError
921+
return FAILURE;
922+
}
923+
919924
/* pass */
920925
} else if (zend_string_equals_literal(name, "trim")
921926
|| zend_string_equals_literal(name, "rtrim")
@@ -1015,6 +1020,7 @@ static inline int ct_eval_func_call(
10151020
}
10161021
}
10171022
/* pass */
1023+
// todo: version_compare with 3 arguments got removed, as we should add a proper check for the comperator, else we hide a ValueError
10181024
} else if (zend_string_equals_literal(name, "str_replace")) {
10191025
if (Z_TYPE_P(args[0]) != IS_STRING
10201026
|| Z_TYPE_P(args[1]) != IS_STRING

0 commit comments

Comments
 (0)