diff options
author | Xinchen Hui <laruence@php.net> | 2014-12-21 23:16:25 -0500 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2014-12-21 23:16:25 -0500 |
commit | c24125e2f90e7cc88c8a2c3560bc458dbc8b704d (patch) | |
tree | ff9486e671818f4a401acfeafab1b93537375d75 | |
parent | 201e1b8a8d22b244b4e22d239db55ea85ccc6983 (diff) | |
download | php-git-c24125e2f90e7cc88c8a2c3560bc458dbc8b704d.tar.gz |
Micro optimization
-rw-r--r-- | Zend/zend_object_handlers.c | 4 | ||||
-rw-r--r-- | Zend/zend_operators.c | 23 | ||||
-rw-r--r-- | Zend/zend_operators.h | 6 | ||||
-rw-r--r-- | ext/spl/spl_array.c | 4 | ||||
-rw-r--r-- | ext/standard/basic_functions.c | 10 |
5 files changed, 16 insertions, 31 deletions
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index a0f3bfc45b..644edfd61f 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -1286,8 +1286,6 @@ ZEND_API union _zend_function *zend_std_get_constructor(zend_object *zobj) /* {{ } /* }}} */ -int zend_compare_symbol_tables_i(HashTable *ht1, HashTable *ht2); - static int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */ { zend_object *zobj1, *zobj2; @@ -1343,7 +1341,7 @@ static int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */ if (!zobj2->properties) { rebuild_object_properties(zobj2); } - return zend_compare_symbol_tables_i(zobj1->properties, zobj2->properties); + return zend_compare_symbol_tables(zobj1->properties, zobj2->properties); } } /* }}} */ diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 9688e95414..17937ded9e 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1791,7 +1791,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ return SUCCESS; case TYPE_PAIR(IS_ARRAY, IS_ARRAY): - zend_compare_arrays(result, op1, op2); + ZVAL_LONG(result, zend_compare_arrays(op1, op2)); return SUCCESS; case TYPE_PAIR(IS_NULL, IS_NULL): @@ -2601,35 +2601,28 @@ static int hash_zval_compare_function(zval *z1, zval *z2) /* {{{ */ } /* }}} */ -ZEND_API int zend_compare_symbol_tables_i(HashTable *ht1, HashTable *ht2) /* {{{ */ +ZEND_API int zend_compare_symbol_tables(HashTable *ht1, HashTable *ht2) /* {{{ */ { return ht1 == ht2 ? 0 : zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0); } /* }}} */ -ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2) /* {{{ */ +ZEND_API int zend_compare_arrays(zval *a1, zval *a2) /* {{{ */ { - ZVAL_LONG(result, ht1 == ht2 ? 0 : zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0)); + return zend_compare_symbol_tables(Z_ARRVAL_P(a1), Z_ARRVAL_P(a2)); } /* }}} */ -ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2) /* {{{ */ -{ - zend_compare_symbol_tables(result, Z_ARRVAL_P(a1), Z_ARRVAL_P(a2)); -} -/* }}} */ - -ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2) /* {{{ */ +ZEND_API int zend_compare_objects(zval *o1, zval *o2) /* {{{ */ { if (Z_OBJ_P(o1) == Z_OBJ_P(o2)) { - ZVAL_LONG(result, 0); - return; + return 0; } if (Z_OBJ_HT_P(o1)->compare_objects == NULL) { - ZVAL_LONG(result, 1); + return 1; } else { - ZVAL_LONG(result, Z_OBJ_HT_P(o1)->compare_objects(o1, o2)); + return Z_OBJ_HT_P(o1)->compare_objects(o1, o2); } } /* }}} */ diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 57120228fb..5a20ac72a7 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -338,9 +338,9 @@ ZEND_API int zend_binary_strcasecmp_l(const char *s1, size_t len1, const char *s ZEND_API int zend_binary_strncasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2, size_t length); ZEND_API zend_long zendi_smart_strcmp(zval *s1, zval *s2); -ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2); -ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2); -ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2); +ZEND_API int zend_compare_symbol_tables(HashTable *ht1, HashTable *ht2); +ZEND_API int zend_compare_arrays(zval *a1, zval *a2); +ZEND_API int zend_compare_objects(zval *o1, zval *o2); ZEND_API int zend_atoi(const char *str, int str_len); ZEND_API zend_long zend_atol(const char *str, int str_len); diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 4f6efcac7d..57ba65bf8e 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -949,15 +949,13 @@ static int spl_array_compare_objects(zval *o1, zval *o2) /* {{{ */ spl_array_object *intern1, *intern2; int result = 0; - zval temp_zv; intern1 = Z_SPLARRAY_P(o1); intern2 = Z_SPLARRAY_P(o2); ht1 = spl_array_get_hash_table(intern1, 0); ht2 = spl_array_get_hash_table(intern2, 0); - zend_compare_symbol_tables(&temp_zv, ht1, ht2); - result = (int)Z_LVAL(temp_zv); + result = zend_compare_symbol_tables(ht1, ht2); /* if we just compared std.properties, don't do it again */ if (result == 0 && !(ht1 == intern1->std.properties && ht2 == intern2->std.properties)) { diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index cef9c6d967..ed5206aa69 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4937,15 +4937,11 @@ static int user_tick_function_compare(user_tick_function_entry * tick_fe1, user_ int ret; if (Z_TYPE_P(func1) == IS_STRING && Z_TYPE_P(func2) == IS_STRING) { - ret = (zend_binary_zval_strcmp(func1, func2) == 0); + ret = zend_binary_zval_strcmp(func1, func2) == 0; } else if (Z_TYPE_P(func1) == IS_ARRAY && Z_TYPE_P(func2) == IS_ARRAY) { - zval result; - zend_compare_arrays(&result, func1, func2); - ret = (Z_LVAL(result) == 0); + ret = zend_compare_arrays(func1, func2) == 0; } else if (Z_TYPE_P(func1) == IS_OBJECT && Z_TYPE_P(func2) == IS_OBJECT) { - zval result; - zend_compare_objects(&result, func1, func2); - ret = (Z_LVAL(result) == 0); + ret = zend_compare_objects(func1, func2) == 0; } else { ret = 0; } |