mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 08:48:39 +09:00
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
This commit is contained in:
parent
35fd97ab97
commit
afc180e2f1
4 changed files with 1019 additions and 981 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue