[PHP-CVS] [php-src] master: Zend: Use pointer hash lookups for property metadata

[email protected] (Weilin Du)
Newsgroups php.cvs
Message-ID <[email protected]>
Author: Weilin Du (LamentXU123)
Date: 2026-08-16T16:35:06+08:00

Commit: https://github.com/php/php-src/commit/5f9e5e0886586d05f150add6b2f8b17734d67d9e
Raw diff: https://github.com/php/php-src/commit/5f9e5e0886586d05f150add6b2f8b17734d67d9e.diff

Zend: Use pointer hash lookups for property metadata

Changed paths:
  M  Zend/zend_object_handlers.c


Diff:

diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 45b6be2cc9eb..95046d1589d4 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -294,13 +294,9 @@ static zend_never_inline int is_protected_compatible_scope(const zend_class_entr
 
 static zend_never_inline zend_property_info *zend_get_parent_private_property(const zend_class_entry *scope, const zend_class_entry *ce, zend_string *member) /* {{{ */
 {
-	zval *zv;
-	zend_property_info *prop_info;
-
 	if (scope != ce && scope && is_derived_class(ce, scope)) {
-		zv = zend_hash_find(&scope->properties_info, member);
-		if (zv != NULL) {
-			prop_info = (zend_property_info*)Z_PTR_P(zv);
+		zend_property_info *prop_info = zend_hash_find_ptr(&scope->properties_info, member);
+		if (prop_info != NULL) {
 			if ((prop_info->flags & ZEND_ACC_PRIVATE)
 			 && prop_info->ce == scope) {
 				return prop_info;
@@ -364,7 +360,6 @@ static zend_always_inline const zend_class_entry *get_fake_or_executed_scope(voi
 
 static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *ce, zend_string *member, int silent, void **cache_slot, const zend_property_info **info_ptr) /* {{{ */
 {
-	zval *zv;
 	zend_property_info *property_info;
 	uint32_t flags;
 	uintptr_t offset;
@@ -375,7 +370,7 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
 	}
 
 	if (UNEXPECTED(zend_hash_num_elements(&ce->properties_info) == 0)
-	 || UNEXPECTED((zv = zend_hash_find(&ce->properties_info, member)) == NULL)) {
+	 || UNEXPECTED((property_info = zend_hash_find_ptr(&ce->properties_info, member)) == NULL)) {
 		if (UNEXPECTED(ZSTR_VAL(member)[0] == '\0') && ZSTR_LEN(member) != 0) {
 			if (!silent) {
 				zend_bad_property_name();
@@ -390,7 +385,6 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
 		return ZEND_DYNAMIC_PROPERTY_OFFSET;
 	}
 
-	property_info = (zend_property_info*)Z_PTR_P(zv);
 	flags = property_info->flags;
 
 	if (flags & (ZEND_ACC_CHANGED|ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED)) {
@@ -474,12 +468,11 @@ static ZEND_COLD void zend_wrong_offset(zend_class_entry *ce, zend_string *membe
 
 ZEND_API zend_property_info *zend_get_property_info(const zend_class_entry *ce, zend_string *member, int silent) /* {{{ */
 {
-	zval *zv;
 	zend_property_info *property_info;
 	uint32_t flags;
 
 	if (UNEXPECTED(zend_hash_num_elements(&ce->properties_info) == 0)
-	 || EXPECTED((zv = zend_hash_find(&ce->properties_info, member)) == NULL)) {
+	 || EXPECTED((property_info = zend_hash_find_ptr(&ce->properties_info, member)) == NULL)) {
 		if (UNEXPECTED(ZSTR_VAL(member)[0] == '\0') && ZSTR_LEN(member) != 0) {
 			if (!silent) {
 				zend_bad_property_name();
@@ -490,7 +483,6 @@ ZEND_API zend_property_info *zend_get_property_info(const zend_class_entry *ce,
 		return NULL;
 	}
 
-	property_info = (zend_property_info*)Z_PTR_P(zv);
 	flags = property_info->flags;
 
 	if (flags & (ZEND_ACC_CHANGED|ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED)) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.