Skip to content

Commit 8a37f6b

Browse files
committed
Allow compacting LITERAL_VALUE with related literals
Nowadays we include the content of all the related literals in the cache key, so DECLARE_CLASS (where both literals cannot be derived from each other) no longer needs this special case.
1 parent 82d407b commit 8a37f6b

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

Zend/Optimizer/compact_literals.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ static zend_string *create_str_cache_key(zval *literal, uint32_t flags)
119119
if (num_related == 1) {
120120
return zend_string_copy(Z_STR_P(literal));
121121
}
122-
if ((flags & LITERAL_KIND_MASK) == LITERAL_VALUE) {
123-
/* Don't merge LITERAL_VALUE that has related literals */
124-
return NULL;
125-
}
126122

127123
/* Concatenate all the related literals for the cache key. */
128124
zend_string *key;
@@ -435,12 +431,9 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
435431
break;
436432
case IS_STRING: {
437433
key = create_str_cache_key(&op_array->literals[i], info[i].flags);
438-
if (key && (pos = zend_hash_find(&hash, key)) != NULL &&
439-
Z_TYPE(op_array->literals[Z_LVAL_P(pos)]) == IS_STRING &&
440-
LITERAL_NUM_RELATED(info[i].flags) == LITERAL_NUM_RELATED(info[Z_LVAL_P(pos)].flags) &&
441-
(LITERAL_NUM_RELATED(info[i].flags) != 2 ||
442-
((info[i].flags & LITERAL_KIND_MASK) != LITERAL_VALUE &&
443-
(info[Z_LVAL_P(pos)].flags & LITERAL_KIND_MASK) != LITERAL_VALUE))) {
434+
if ((pos = zend_hash_find(&hash, key)) != NULL) {
435+
ZEND_ASSERT(Z_TYPE(op_array->literals[Z_LVAL_P(pos)]) == IS_STRING &&
436+
LITERAL_NUM_RELATED(info[i].flags) == LITERAL_NUM_RELATED(info[Z_LVAL_P(pos)].flags));
444437
zend_string_release_ex(key, 0);
445438
map[i] = Z_LVAL_P(pos);
446439
zval_ptr_dtor_nogc(&op_array->literals[i]);

0 commit comments

Comments
 (0)