Skip to content

Commit 331e6ae

Browse files
authored
tidy: Avoid some work when creating attributes (#20390)
We know these can't be numeric strings, so directly use the hash table APIs. Also use ZVAL_STRING_FAST because many attributes are 0/1 chars long.
1 parent 8eff4c3 commit 331e6ae

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ext/tidy/tidy.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,12 +616,14 @@ static void tidy_add_node_default_properties(PHPTidyObj *obj)
616616
do {
617617
const char *attr_name = tidyAttrName(tempattr);
618618
if (attr_name) {
619+
zval value;
619620
const char *val = tidyAttrValue(tempattr);
620621
if (val) {
621-
add_assoc_string(&attribute, attr_name, val);
622+
ZVAL_STRING_FAST(&value, val);
622623
} else {
623-
add_assoc_str(&attribute, attr_name, zend_empty_string);
624+
ZVAL_EMPTY_STRING(&value);
624625
}
626+
zend_hash_str_add_new(Z_ARRVAL(attribute), attr_name, strlen(attr_name), &value);
625627
}
626628
} while((tempattr = tidyAttrNext(tempattr)));
627629
} else {

0 commit comments

Comments
 (0)