summaryrefslogtreecommitdiff
path: root/parser/html/nsHtml5ElementName.h
diff options
context:
space:
mode:
Diffstat (limited to 'parser/html/nsHtml5ElementName.h')
-rw-r--r--parser/html/nsHtml5ElementName.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/parser/html/nsHtml5ElementName.h b/parser/html/nsHtml5ElementName.h
index 6bf31a0add..737ac6b18d 100644
--- a/parser/html/nsHtml5ElementName.h
+++ b/parser/html/nsHtml5ElementName.h
@@ -108,10 +108,29 @@ class nsHtml5ElementName
return !(flags & nsHtml5ElementName::NOT_INTERNED);
}
+ 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 nsHtml5ElementName* elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
{
uint32_t hash = nsHtml5ElementName::bufToHash(buf, length);
- int32_t index = nsHtml5ElementName::ELEMENT_HASHES.binarySearch(hash);
+ jArray<int32_t,int32_t> hashes;
+ hashes = nsHtml5ElementName::ELEMENT_HASHES;
+ int32_t index = levelOrderBinarySearch(hashes, hash);
if (index < 0) {
return nullptr;
} else {