Skip to content

Commit 794c5fb

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 794c5fb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ext/opcache/Optimizer/sccp.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ static inline int ct_eval_func_call(
844844
|| zend_string_equals_literal(name, "urldecode")
845845
|| zend_string_equals_literal(name, "rawurlencode")
846846
|| zend_string_equals_literal(name, "rawurldecode")
847+
|| zend_string_equals_literal(name, "php_uname")
847848
|| zend_string_equals_literal(name, "strtoupper")
848849
|| zend_string_equals_literal(name, "strtolower")
849850
|| zend_string_equals_literal(name, "dirname")
@@ -872,7 +873,7 @@ static inline int ct_eval_func_call(
872873
} ZEND_HASH_FOREACH_END();
873874
/* pass */
874875
} else if (zend_string_equals_literal(name, "implode")
875-
|| zend_string_equals_literal(name, "array_unique")) {
876+
|| zend_string_equals_literal(name, "array_unique")) {
876877
zval *entry;
877878

878879
if (Z_TYPE_P(args[0]) != IS_ARRAY) {
@@ -916,6 +917,11 @@ static inline int ct_eval_func_call(
916917
|| (Z_TYPE_P(args[1]) != IS_LONG)) {
917918
return FAILURE;
918919
}
920+
if (Z_LVAL_P(args[1]) < 1) {
921+
// levels must be >= 1, else we get a ValueError
922+
return FAILURE;
923+
}
924+
919925
/* pass */
920926
} else if (zend_string_equals_literal(name, "trim")
921927
|| zend_string_equals_literal(name, "rtrim")
@@ -1015,6 +1021,7 @@ static inline int ct_eval_func_call(
10151021
}
10161022
}
10171023
/* pass */
1024+
// todo: version_compare with 3 arguments got removed, as we should add a proper check for the comperator, else we hide a ValueError
10181025
} else if (zend_string_equals_literal(name, "str_replace")) {
10191026
if (Z_TYPE_P(args[0]) != IS_STRING
10201027
|| Z_TYPE_P(args[1]) != IS_STRING

0 commit comments

Comments
 (0)