[php-src] PR #13897: Cleanup and optimize attribute value reading

From: Date: Sat, 06 Apr 2024 12:25:30 +0000
Subject: [php-src] PR #13897: Cleanup and optimize attribute value reading
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-25641@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/13897 Author: nielsdos 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: ```php $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 } ```

« previous php.git-pulls (#25641) next »