summaryrefslogtreecommitdiffstats
path: root/parser/html/nsHtml5AttributeName.h
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-18 17:35:09 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:38 -0500
commitfce396323da02695c266579d229f11bf0959280b (patch)
tree67a01e6a1274d59dbd6304660ab5576f4b636fe2 /parser/html/nsHtml5AttributeName.h
parenta8511d983c05f52bcdeef57af0947f9e21487bba (diff)
downloadUXP-fce396323da02695c266579d229f11bf0959280b.tar
UXP-fce396323da02695c266579d229f11bf0959280b.tar.gz
UXP-fce396323da02695c266579d229f11bf0959280b.tar.lz
UXP-fce396323da02695c266579d229f11bf0959280b.tar.xz
UXP-fce396323da02695c266579d229f11bf0959280b.zip
Bug 1366241 - Change memory layout of element name and attribute name hashes in HTML parser from sorted to level order BST in order to take advantage of cache during lookup.
HTML Regen. Tag UXP Issue #1344
Diffstat (limited to 'parser/html/nsHtml5AttributeName.h')
-rw-r--r--parser/html/nsHtml5AttributeName.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/parser/html/nsHtml5AttributeName.h b/parser/html/nsHtml5AttributeName.h
index 3b546e5e2..c2c93a4d2 100644
--- a/parser/html/nsHtml5AttributeName.h
+++ b/parser/html/nsHtml5AttributeName.h
@@ -76,10 +76,29 @@ class nsHtml5AttributeName
static nsIAtom** COLONIFIED_LOCAL(nsIAtom* name, nsIAtom* suffix);
public:
static nsIAtom** SAME_LOCAL(nsIAtom* name);
+ inline static int32_t levelOrderBinarySearch(jArray<int32_t,int32_t> data, int32_t key)
+ {
+ int32_t n = data.length;
+ int32_t i = 0;
+ while (i < n) {
+ int32_t val = data[i];
+ if (val < key) {
+ i = 2 * i + 2;
+ } else if (val > key) {
+ i = 2 * i + 1;
+ } else {
+ return i;
+ }
+ }
+ return -1;
+ }
+
inline static nsHtml5AttributeName* nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
{
uint32_t hash = nsHtml5AttributeName::bufToHash(buf, length);
- int32_t index = nsHtml5AttributeName::ATTRIBUTE_HASHES.binarySearch(hash);
+ jArray<int32_t,int32_t> hashes;
+ hashes = nsHtml5AttributeName::ATTRIBUTE_HASHES;
+ int32_t index = levelOrderBinarySearch(hashes, hash);
if (index < 0) {
return nullptr;
}