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

Small optimization in dom_local_name_compare_ex() (#15950)

We can use `memcmp()` directly and skip some of the logic handling
in `zend_binary_strcmp()`. `perf record` shows a reduction for
`dom_html5_serializes_as_void()` from 3.12% to 0.77%.
This commit is contained in:
Niels Dossche
2024-09-20 08:11:13 +02:00
committed by GitHub
parent 090b53bc44
commit 7e6e71255e

View File

@@ -20,9 +20,10 @@
#include <Zend/zend_types.h>
#include <libxml/tree.h>
/* The lengths are merely here for optimization purposes, this cannot be used to compare substrings. */
static zend_always_inline bool dom_local_name_compare_ex(const xmlNode *node, const char *tag, size_t tag_length, size_t name_length)
{
return name_length == tag_length && zend_binary_strcmp((const char *) node->name, name_length, tag, tag_length) == 0;
return name_length == tag_length && memcmp((const char *) node->name, tag, name_length + 1) == 0;
}
#endif