
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%.
30 lines
1.4 KiB
C
30 lines
1.4 KiB
C
/*
|
|
+----------------------------------------------------------------------+
|
|
| Copyright (c) The PHP Group |
|
|
+----------------------------------------------------------------------+
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
| available through the world-wide-web at the following url: |
|
|
| https://www.php.net/license/3_01.txt |
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
+----------------------------------------------------------------------+
|
|
| Authors: Niels Dossche <nielsdos@php.net> |
|
|
+----------------------------------------------------------------------+
|
|
*/
|
|
|
|
#ifndef SERIALIZE_COMMON_H
|
|
#define SERIALIZE_COMMON_H
|
|
|
|
#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 && memcmp((const char *) node->name, tag, name_length + 1) == 0;
|
|
}
|
|
|
|
#endif
|