com php-src: Micro optimization: Zend/zend_object_handlers .c Zend/zend_operators.c Zend/zend_operators.h ext/spl/spl_array.c
ext/standard/basic_functions.c
| From: | Xinchen Hui | Date: | Mon, 22 Dec 2014 04:16:25 +0000 |
| Subject: | com php-src: Micro optimization: Zend/zend_object_handlers .c Zend/zend_operators.c Zend/zend_operators.h ext/spl/spl_array.c ext/standard/basic_functions.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-83816@lists.php.net to get a copy of this message | ||
Commit: c24125e2f90e7cc88c8a2c3560bc458dbc8b704d
Author: Xinchen Hui <laruence@php.net> Sun, 21 Dec 2014 23:16:25 -0500
Parents: 201e1b8a8d22b244b4e22d239db55ea85ccc6983
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c24125e2f90e7cc88c8a2c3560bc458dbc8b704d
Log:
Micro optimization
Changed paths:
M Zend/zend_object_handlers.c
M Zend/zend_operators.c
M Zend/zend_operators.h
M ext/spl/spl_array.c
M ext/standard/basic_functions.c
Diff:
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index a0f3bfc..644edfd 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 9688e95..17937de 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 5712022..5a20ac7 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 4f6efca..57ba65b 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 cef9c6d..ed5206a 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;
}