Skip to content

Commit 3e1e119

Browse files
committed
Inline zend_std_get_properties calls
1 parent 909fd8e commit 3e1e119

12 files changed

+28
-20
lines changed

Zend/zend_API.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties)
17651765
ZSTR_VAL(object->ce->name), property_info != ZEND_WRONG_PROPERTY_INFO ? zend_get_unmangled_property_name(key): "");
17661766
}
17671767

1768-
prop = zend_hash_update(zend_std_get_properties(object), key, prop);
1768+
prop = zend_hash_update(zend_std_get_properties_ex(object), key, prop);
17691769
zval_add_ref(prop);
17701770
}
17711771
} else {
@@ -1777,7 +1777,7 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties)
17771777
ZSTR_VAL(object->ce->name), h);
17781778
}
17791779

1780-
prop = zend_hash_index_update(zend_std_get_properties(object), h, prop);
1780+
prop = zend_hash_index_update(zend_std_get_properties_ex(object), h, prop);
17811781
zval_add_ref(prop);
17821782
}
17831783
} ZEND_HASH_FOREACH_END();

Zend/zend_object_handlers.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
called, we cal __call handler.
6363
*/
6464

65-
static void rebuild_object_properties(zend_object *zobj) /* {{{ */
65+
void rebuild_object_properties(zend_object *zobj) /* {{{ */
6666
{
6767
if (!zobj->properties) {
6868
zend_property_info *prop_info;
@@ -129,10 +129,7 @@ ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj) /*
129129

130130
ZEND_API HashTable *zend_std_get_properties(zend_object *zobj) /* {{{ */
131131
{
132-
if (!zobj->properties) {
133-
rebuild_object_properties(zobj);
134-
}
135-
return zobj->properties;
132+
return zend_std_get_properties_ex(zobj);
136133
}
137134
/* }}} */
138135

Zend/zend_object_handlers.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
267267
ZEND_API zend_string *zend_std_get_class_name(const zend_object *zobj);
268268
ZEND_API int zend_std_compare_objects(zval *o1, zval *o2);
269269
ZEND_API zend_result zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only);
270+
void rebuild_object_properties(zend_object *zobj);
271+
272+
static inline HashTable *zend_std_get_properties_ex(zend_object *object)
273+
{
274+
if (!object->properties) {
275+
rebuild_object_properties(object);
276+
}
277+
return object->properties;
278+
}
270279

271280
ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj);
272281

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2519,7 +2519,7 @@ ZEND_VM_C_LABEL(fast_assign_obj):
25192519
Z_TRY_ADDREF_P(value);
25202520
}
25212521
}
2522-
zend_hash_add_new(zend_std_get_properties(zobj), name, value);
2522+
zend_hash_add_new(zend_std_get_properties_ex(zobj), name, value);
25232523
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
25242524
ZVAL_COPY(EX_VAR(opline->result.var), value);
25252525
}

ext/date/php_date.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,8 @@ static void initialize_date_period_properties(php_period_obj *period_obj)
15151515
{
15161516
zval zv;
15171517

1518-
zend_std_get_properties(&period_obj->std);
1518+
/* rebuild properties */
1519+
zend_std_get_properties_ex(&period_obj->std);
15191520

15201521
create_date_period_datetime(period_obj->start, period_obj->start_ce, &zv);
15211522
write_date_period_property(&period_obj->std, "start", sizeof("start") - 1, &zv);
@@ -1650,7 +1651,8 @@ static void date_period_it_move_forward(zend_object_iterator *iter)
16501651

16511652
date_period_advance(it_time, object->interval);
16521653

1653-
zend_std_get_properties(&object->std);
1654+
/* rebuild properties */
1655+
zend_std_get_properties_ex(&object->std);
16541656

16551657
create_date_period_datetime(object->current, object->start_ce, &current_zv);
16561658
zend_string *property_name = ZSTR_INIT_LITERAL("current", 0);

ext/pdo/pdo_dbh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ zend_object *pdo_dbh_new(zend_class_entry *ce)
15061506
zend_object_std_init(&dbh->std, ce);
15071507
object_properties_init(&dbh->std, ce);
15081508
/* rebuild properties */
1509-
zend_std_get_properties(&dbh->std);
1509+
zend_std_get_properties_ex(&dbh->std);
15101510
dbh->inner = ecalloc(1, sizeof(pdo_dbh_t));
15111511
dbh->inner->def_stmt_ce = pdo_dbstmt_ce;
15121512

ext/pdo/pdo_stmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,7 @@ static HashTable *row_get_properties_for(zend_object *object, zend_prop_purpose
24262426
return zend_std_get_properties_for(object, purpose);
24272427
}
24282428

2429-
props = zend_array_dup(zend_std_get_properties(&stmt->std));
2429+
props = zend_array_dup(zend_std_get_properties_ex(&stmt->std));
24302430
for (i = 0; i < stmt->column_count; i++) {
24312431
if (zend_string_equals_literal(stmt->columns[i].name, "queryString")) {
24322432
continue;

ext/random/engine_mt19937.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ PHP_METHOD(Random_Engine_Mt19937, __debugInfo)
388388

389389
ZEND_PARSE_PARAMETERS_NONE();
390390

391-
ZVAL_ARR(return_value, zend_array_dup(zend_std_get_properties(&engine->std)));
391+
ZVAL_ARR(return_value, zend_array_dup(zend_std_get_properties_ex(&engine->std)));
392392

393393
if (engine->engine.algo->serialize) {
394394
array_init(&t);

ext/spl/spl_array.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static inline HashTable **spl_array_get_hash_table_ptr(spl_array_object* intern)
6565
//??? TODO: Delay duplication for arrays; only duplicate for write operations
6666
if (intern->ar_flags & SPL_ARRAY_IS_SELF) {
6767
/* rebuild properties */
68-
zend_std_get_properties(&intern->std);
68+
zend_std_get_properties_ex(&intern->std);
6969
return &intern->std.properties;
7070
} else if (intern->ar_flags & SPL_ARRAY_USE_OTHER) {
7171
spl_array_object *other = Z_SPLARRAY_P(&intern->array);
@@ -75,7 +75,7 @@ static inline HashTable **spl_array_get_hash_table_ptr(spl_array_object* intern)
7575
} else {
7676
zend_object *obj = Z_OBJ(intern->array);
7777
/* rebuild properties */
78-
zend_std_get_properties(obj);
78+
zend_std_get_properties_ex(obj);
7979
if (GC_REFCOUNT(obj->properties) > 1) {
8080
if (EXPECTED(!(GC_FLAGS(obj->properties) & IS_ARRAY_IMMUTABLE))) {
8181
GC_DELREF(obj->properties);
@@ -769,7 +769,7 @@ static HashTable *spl_array_get_properties_for(zend_object *object, zend_prop_pu
769769
static inline HashTable* spl_array_get_debug_info(zend_object *obj) /* {{{ */
770770
{
771771
spl_array_object *intern = spl_array_from_obj(obj);
772-
HashTable *properties = zend_std_get_properties(&intern->std);
772+
HashTable *properties = zend_std_get_properties_ex(&intern->std);
773773

774774
if (intern->ar_flags & SPL_ARRAY_IS_SELF) {
775775
return zend_array_dup(properties);
@@ -1263,7 +1263,7 @@ PHP_METHOD(ArrayObject, serialize)
12631263
/* members */
12641264
smart_str_appendl(&buf, "m:", 2);
12651265

1266-
ZVAL_ARR(&members, zend_std_get_properties(&intern->std));
1266+
ZVAL_ARR(&members, zend_std_get_properties_ex(&intern->std));
12671267

12681268
php_var_serialize(&buf, &members, &var_hash); /* finishes the string */
12691269

ext/spl/spl_directory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ static inline HashTable *spl_filesystem_object_get_debug_info(zend_object *objec
602602
zend_string *path_name;
603603

604604
// TODO Do zend_new_array() + zend_hash_copy() trick?
605-
debug_info = zend_array_dup(zend_std_get_properties(&intern->std));
605+
debug_info = zend_array_dup(zend_std_get_properties_ex(&intern->std));
606606

607607
path_name = spl_filesystem_object_get_pathname(intern);
608608
if (path_name) {

ext/spl/spl_dllist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ static inline HashTable* spl_dllist_object_get_debug_info(zend_object *obj) /* {
427427
spl_ptr_llist_element *current = intern->llist->head;
428428
zval tmp, dllist_array;
429429
HashTable *debug_info;
430-
HashTable *properties = zend_std_get_properties(&intern->std);
430+
HashTable *properties = zend_std_get_properties_ex(&intern->std);
431431

432432
/* +2 As we are adding 2 additional key-entries */
433433
debug_info = zend_new_array(zend_hash_num_elements(properties) + 2);

ext/spl/spl_heap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static inline HashTable* spl_heap_object_get_debug_info(const zend_class_entry *
507507
spl_heap_object *intern = spl_heap_from_obj(obj);
508508
zval tmp, heap_array;
509509
HashTable *debug_info;
510-
HashTable *properties = zend_std_get_properties(&intern->std);
510+
HashTable *properties = zend_std_get_properties_ex(&intern->std);
511511

512512
/* +3 As we are adding 3 additional key-entries */
513513
debug_info = zend_new_array(zend_hash_num_elements(properties) + 3);

0 commit comments

Comments
 (0)