You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cleanup and optimize attribute value reading (php#13897)
When the attribute has a single text child, we can avoid an allocating
call to libxml2 and read the contents directly.
On my i7-4790, I tested the optimization with both the $value and
$nodeValue property.
```
Summary
./sapi/cli/php bench_value.php ran
1.82 ± 0.09 times faster than ./sapi/cli/php_old bench_value.php
Summary
./sapi/cli/php bench_nodeValue.php ran
1.78 ± 0.10 times faster than ./sapi/cli/php_old bench_nodeValue.php
```
Test code:
```
$dom = new DOMDocument;
$dom->loadXML('<root attrib="this is a relatively short text"/>');
$attrib = $dom->documentElement->attributes[0];
for ($i=0; $i<1000*1000; $i++) {
$attrib->value; // or nodeValue
}
```
0 commit comments