mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
Bug 1355787 - nsIdentifierMapEntry should let one to use either strings or atoms as keys to avoid slow string assignments when possible.
Tag #1375
This commit is contained in:
parent
c21eecd1b3
commit
15f6d2efda
4 changed files with 76 additions and 22 deletions
|
|
@ -537,7 +537,7 @@ nsIdentifierMapEntry::HasIdElementExposedAsHTMLDocumentProperty()
|
|||
size_t
|
||||
nsIdentifierMapEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
return nsStringHashKey::SizeOfExcludingThis(aMallocSizeOf);
|
||||
return mKey.mString.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
||||
}
|
||||
|
||||
// Helper structs for the content->subdoc map
|
||||
|
|
@ -2704,8 +2704,7 @@ nsDocument::AddToNameTable(Element *aElement, nsIAtom* aName)
|
|||
"Only put elements that need to be exposed as document['name'] in "
|
||||
"the named table.");
|
||||
|
||||
nsIdentifierMapEntry *entry =
|
||||
mIdentifierMap.PutEntry(nsDependentAtomString(aName));
|
||||
nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aName);
|
||||
|
||||
// Null for out-of-memory
|
||||
if (entry) {
|
||||
|
|
@ -2724,8 +2723,7 @@ nsDocument::RemoveFromNameTable(Element *aElement, nsIAtom* aName)
|
|||
if (mIdentifierMap.Count() == 0)
|
||||
return;
|
||||
|
||||
nsIdentifierMapEntry *entry =
|
||||
mIdentifierMap.GetEntry(nsDependentAtomString(aName));
|
||||
nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aName);
|
||||
if (!entry) // Could be false if the element was anonymous, hence never added
|
||||
return;
|
||||
|
||||
|
|
@ -2739,8 +2737,7 @@ nsDocument::RemoveFromNameTable(Element *aElement, nsIAtom* aName)
|
|||
void
|
||||
nsDocument::AddToIdTable(Element *aElement, nsIAtom* aId)
|
||||
{
|
||||
nsIdentifierMapEntry *entry =
|
||||
mIdentifierMap.PutEntry(nsDependentAtomString(aId));
|
||||
nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aId);
|
||||
|
||||
if (entry) { /* True except on OOM */
|
||||
if (nsGenericHTMLElement::ShouldExposeIdAsHTMLDocumentProperty(aElement) &&
|
||||
|
|
@ -2762,8 +2759,7 @@ nsDocument::RemoveFromIdTable(Element *aElement, nsIAtom* aId)
|
|||
return;
|
||||
}
|
||||
|
||||
nsIdentifierMapEntry *entry =
|
||||
mIdentifierMap.GetEntry(nsDependentAtomString(aId));
|
||||
nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aId);
|
||||
if (!entry) // Can be null for XML elements with changing ids.
|
||||
return;
|
||||
|
||||
|
|
@ -4783,7 +4779,7 @@ nsDocument::AddIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
|
|||
if (!CheckGetElementByIdArg(id))
|
||||
return nullptr;
|
||||
|
||||
nsIdentifierMapEntry *entry = mIdentifierMap.PutEntry(id);
|
||||
nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aID);
|
||||
NS_ENSURE_TRUE(entry, nullptr);
|
||||
|
||||
entry->AddContentChangeCallback(aObserver, aData, aForImage);
|
||||
|
|
@ -4799,7 +4795,7 @@ nsDocument::RemoveIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
|
|||
if (!CheckGetElementByIdArg(id))
|
||||
return;
|
||||
|
||||
nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(id);
|
||||
nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aID);
|
||||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue