]> granicus.if.org Git - php/commitdiff
SCCP: Optimize strpos with empty needle
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 30 Mar 2020 08:37:12 +0000 (10:37 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 30 Mar 2020 08:37:22 +0000 (10:37 +0200)
This is no longer special cases in PHP 8.

ext/opcache/Optimizer/sccp.c

index 60ddd9f508d0b20495deacedada2b0fdbb66ec4e..f9eef41af91e3d8e85ab9dd737cdb32437dd9fb4 100644 (file)
@@ -886,13 +886,6 @@ static inline int ct_eval_func_call(
                                return FAILURE;
                        }
                        /* pass */
-               } else if (zend_string_equals_literal(name, "strpos")) {
-                       if (Z_TYPE_P(args[0]) != IS_STRING
-                                       || Z_TYPE_P(args[1]) != IS_STRING
-                                       || !Z_STRLEN_P(args[1])) {
-                               return FAILURE;
-                       }
-                       /* pass */
                } else if (zend_string_equals_literal(name, "str_split")) {
                        if (Z_TYPE_P(args[0]) != IS_STRING
                                        || Z_TYPE_P(args[1]) != IS_LONG
@@ -960,7 +953,8 @@ static inline int ct_eval_func_call(
                                } ZEND_HASH_FOREACH_END();
                        }
                        /* pass */
-               } else if (zend_string_equals_literal(name, "version_compare")) {
+               } else if (zend_string_equals_literal(name, "strpos")
+                               || zend_string_equals_literal(name, "version_compare")) {
                        if (Z_TYPE_P(args[0]) != IS_STRING
                                        || Z_TYPE_P(args[1]) != IS_STRING) {
                                return FAILURE;