Skip to content

Commit 92c1158

Browse files
committed
Address review comments. Remove pointless XORing.
Don't move this into a utility function, it would be the same as `(zend_long)Z_OBJ_HANDLE_P(obj)`
1 parent 6653798 commit 92c1158

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

ext/spl/php_spl.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -804,22 +804,18 @@ PHP_FUNCTION(spl_object_id)
804804
Z_PARAM_OBJECT(obj)
805805
ZEND_PARSE_PARAMETERS_END_EX(RETURN_NULL());
806806

807-
RETURN_LONG(php_spl_object_id(obj));
807+
RETURN_LONG((zend_long)Z_OBJ_HANDLE_P(obj));
808808
}
809809
/* }}} */
810810

811-
static void php_spl_init_hash_mask() {
812-
SPL_G(hash_mask_handle) = (intptr_t)(php_mt_rand() >> 1);
813-
SPL_G(hash_mask_handlers) = (intptr_t)(php_mt_rand() >> 1);
814-
SPL_G(hash_mask_init) = 1;
815-
}
816-
817811
PHPAPI zend_string *php_spl_object_hash(zval *obj) /* {{{*/
818812
{
819813
intptr_t hash_handle, hash_handlers;
820814

821815
if (!SPL_G(hash_mask_init)) {
822-
php_spl_init_hash_mask();
816+
SPL_G(hash_mask_handle) = (intptr_t)(php_mt_rand() >> 1);
817+
SPL_G(hash_mask_handlers) = (intptr_t)(php_mt_rand() >> 1);
818+
SPL_G(hash_mask_init) = 1;
823819
}
824820

825821
hash_handle = SPL_G(hash_mask_handle)^(intptr_t)Z_OBJ_HANDLE_P(obj);
@@ -829,20 +825,6 @@ PHPAPI zend_string *php_spl_object_hash(zval *obj) /* {{{*/
829825
}
830826
/* }}} */
831827

832-
PHPAPI zend_long php_spl_object_id(zval *obj) /* {{{*/
833-
{
834-
intptr_t hash_handle;
835-
836-
if (!SPL_G(hash_mask_init)) {
837-
php_spl_init_hash_mask();
838-
}
839-
840-
hash_handle = SPL_G(hash_mask_handle)^(intptr_t)Z_OBJ_HANDLE_P(obj);
841-
842-
return (zend_long) hash_handle;
843-
}
844-
/* }}} */
845-
846828
int spl_build_class_list_string(zval *entry, char **list) /* {{{ */
847829
{
848830
char *res;

ext/spl/php_spl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ PHP_FUNCTION(class_implements);
7171
PHP_FUNCTION(class_uses);
7272

7373
PHPAPI zend_string *php_spl_object_hash(zval *obj);
74-
PHPAPI zend_long php_spl_object_id(zval *obj);
7574

7675
#endif /* PHP_SPL_H */
7776

0 commit comments

Comments
 (0)