From 442efdaaea3c1a06b01aa5f52c2ec05c3d64a0d1 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 19 Jan 2015 09:10:01 -0500 Subject: [PATCH] Optimized is_a --- Zend/zend_builtin_functions.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index f13a2da91d..161bfb2812 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1014,14 +1014,18 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) /* RETURN_FALSE; } - ce = zend_lookup_class_ex(class_name, NULL, 0); - if (!ce) { - retval = 0; + if (!only_subclass && EXPECTED(zend_string_equals(instance_ce->name, class_name))) { + retval = 1; } else { - if (only_subclass && instance_ce == ce) { + ce = zend_lookup_class_ex(class_name, NULL, 0); + if (!ce) { retval = 0; - } else { - retval = instanceof_function(instance_ce, ce); + } else { + if (only_subclass && instance_ce == ce) { + retval = 0; + } else { + retval = instanceof_function(instance_ce, ce); + } } } -- 2.40.0