1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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.
This commit is contained in:
Niels Dossche
2025-11-05 20:13:32 +01:00
committed by GitHub
parent 8eff4c3e78
commit 331e6ae548

View File

@@ -616,12 +616,14 @@ static void tidy_add_node_default_properties(PHPTidyObj *obj)
do {
const char *attr_name = tidyAttrName(tempattr);
if (attr_name) {
zval value;
const char *val = tidyAttrValue(tempattr);
if (val) {
add_assoc_string(&attribute, attr_name, val);
ZVAL_STRING_FAST(&value, val);
} else {
add_assoc_str(&attribute, attr_name, zend_empty_string);
ZVAL_EMPTY_STRING(&value);
}
zend_hash_str_add_new(Z_ARRVAL(attribute), attr_name, strlen(attr_name), &value);
}
} while((tempattr = tidyAttrNext(tempattr)));
} else {