mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 07:07:30 +09:00
add main thread only cache for nsIAtoms to speed up atomization dom/base
add main thread only cache for nsIAtoms to speed up atomization
This commit is contained in:
parent
4ab1401ee6
commit
c4af2549b2
3 changed files with 18 additions and 16 deletions
|
|
@ -1283,7 +1283,7 @@ Element::ToggleAttribute(const nsAString& aName,
|
||||||
if (aForce.WasPassed() && !aForce.Value()) {
|
if (aForce.WasPassed() && !aForce.Value()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsIAtom> nameAtom = NS_Atomize(nameToUse);
|
nsCOMPtr<nsIAtom> nameAtom = NS_AtomizeMainThread(nameToUse);
|
||||||
if (!nameAtom) {
|
if (!nameAtom) {
|
||||||
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
|
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1398,7 +1398,7 @@ Element::GetAttributeNS(const nsAString& aNamespaceURI,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIAtom> name = NS_Atomize(aLocalName);
|
nsCOMPtr<nsIAtom> name = NS_AtomizeMainThread(aLocalName);
|
||||||
bool hasAttr = GetAttr(nsid, name, aReturn);
|
bool hasAttr = GetAttr(nsid, name, aReturn);
|
||||||
if (!hasAttr) {
|
if (!hasAttr) {
|
||||||
SetDOMStringToNull(aReturn);
|
SetDOMStringToNull(aReturn);
|
||||||
|
|
@ -1430,7 +1430,7 @@ Element::RemoveAttributeNS(const nsAString& aNamespaceURI,
|
||||||
const nsAString& aLocalName,
|
const nsAString& aLocalName,
|
||||||
ErrorResult& aError)
|
ErrorResult& aError)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIAtom> name = NS_Atomize(aLocalName);
|
nsCOMPtr<nsIAtom> name = NS_AtomizeMainThread(aLocalName);
|
||||||
int32_t nsid =
|
int32_t nsid =
|
||||||
nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI,
|
nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI,
|
||||||
nsContentUtils::IsChromeDoc(OwnerDoc()));
|
nsContentUtils::IsChromeDoc(OwnerDoc()));
|
||||||
|
|
@ -1518,7 +1518,7 @@ Element::HasAttributeNS(const nsAString& aNamespaceURI,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIAtom> name = NS_Atomize(aLocalName);
|
nsCOMPtr<nsIAtom> name = NS_AtomizeMainThread(aLocalName);
|
||||||
return HasAttr(nsid, name);
|
return HasAttr(nsid, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -742,7 +742,7 @@ nsAttrValue::GetAsAtom() const
|
||||||
{
|
{
|
||||||
switch (Type()) {
|
switch (Type()) {
|
||||||
case eString:
|
case eString:
|
||||||
return NS_Atomize(GetStringValue());
|
return NS_AtomizeMainThread(GetStringValue());
|
||||||
|
|
||||||
case eAtom:
|
case eAtom:
|
||||||
{
|
{
|
||||||
|
|
@ -754,7 +754,7 @@ nsAttrValue::GetAsAtom() const
|
||||||
{
|
{
|
||||||
nsAutoString val;
|
nsAutoString val;
|
||||||
ToString(val);
|
ToString(val);
|
||||||
return NS_Atomize(val);
|
return NS_AtomizeMainThread(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1267,7 +1267,7 @@ nsAttrValue::ParseAtomArray(const nsAString& aValue)
|
||||||
++iter;
|
++iter;
|
||||||
} while (iter != end && !nsContentUtils::IsHTMLWhitespace(*iter));
|
} while (iter != end && !nsContentUtils::IsHTMLWhitespace(*iter));
|
||||||
|
|
||||||
nsCOMPtr<nsIAtom> classAtom = NS_Atomize(Substring(start, iter));
|
nsCOMPtr<nsIAtom> classAtom = NS_AtomizeMainThread(Substring(start, iter));
|
||||||
if (!classAtom) {
|
if (!classAtom) {
|
||||||
Reset();
|
Reset();
|
||||||
return;
|
return;
|
||||||
|
|
@ -1308,7 +1308,7 @@ nsAttrValue::ParseAtomArray(const nsAString& aValue)
|
||||||
++iter;
|
++iter;
|
||||||
} while (iter != end && !nsContentUtils::IsHTMLWhitespace(*iter));
|
} while (iter != end && !nsContentUtils::IsHTMLWhitespace(*iter));
|
||||||
|
|
||||||
classAtom = NS_Atomize(Substring(start, iter));
|
classAtom = NS_AtomizeMainThread(Substring(start, iter));
|
||||||
|
|
||||||
if (!array->AppendElement(classAtom)) {
|
if (!array->AppendElement(classAtom)) {
|
||||||
Reset();
|
Reset();
|
||||||
|
|
@ -1757,7 +1757,7 @@ nsAttrValue::SetMiscAtomOrString(const nsAString* aValue)
|
||||||
"Empty string?");
|
"Empty string?");
|
||||||
MiscContainer* cont = GetMiscContainer();
|
MiscContainer* cont = GetMiscContainer();
|
||||||
if (len <= NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM) {
|
if (len <= NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM) {
|
||||||
nsCOMPtr<nsIAtom> atom = NS_Atomize(*aValue);
|
nsCOMPtr<nsIAtom> atom = NS_AtomizeMainThread(*aValue);
|
||||||
if (atom) {
|
if (atom) {
|
||||||
cont->mStringBits =
|
cont->mStringBits =
|
||||||
reinterpret_cast<uintptr_t>(atom.forget().take()) | eAtomBase;
|
reinterpret_cast<uintptr_t>(atom.forget().take()) | eAtomBase;
|
||||||
|
|
|
||||||
|
|
@ -2947,11 +2947,11 @@ nsContentUtils::SplitQName(const nsIContent* aNamespaceResolver,
|
||||||
if (*aNamespace == kNameSpaceID_Unknown)
|
if (*aNamespace == kNameSpaceID_Unknown)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
*aLocalName = NS_Atomize(Substring(colon + 1, end)).take();
|
*aLocalName = NS_AtomizeMainThread(Substring(colon + 1, end)).take();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*aNamespace = kNameSpaceID_None;
|
*aNamespace = kNameSpaceID_None;
|
||||||
*aLocalName = NS_Atomize(aQName).take();
|
*aLocalName = NS_AtomizeMainThread(aQName).take();
|
||||||
}
|
}
|
||||||
NS_ENSURE_TRUE(aLocalName, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(aLocalName, NS_ERROR_OUT_OF_MEMORY);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
@ -2976,7 +2976,8 @@ nsContentUtils::GetNodeInfoFromQName(const nsAString& aNamespaceURI,
|
||||||
const char16_t* end;
|
const char16_t* end;
|
||||||
qName.EndReading(end);
|
qName.EndReading(end);
|
||||||
|
|
||||||
nsCOMPtr<nsIAtom> prefix = NS_Atomize(Substring(qName.get(), colon));
|
nsCOMPtr<nsIAtom> prefix =
|
||||||
|
NS_AtomizeMainThread(Substring(qName.get(), colon));
|
||||||
|
|
||||||
rv = aNodeInfoManager->GetNodeInfo(Substring(colon + 1, end), prefix,
|
rv = aNodeInfoManager->GetNodeInfo(Substring(colon + 1, end), prefix,
|
||||||
nsID, aNodeType, aNodeInfo);
|
nsID, aNodeType, aNodeInfo);
|
||||||
|
|
@ -3036,7 +3037,7 @@ nsContentUtils::SplitExpatName(const char16_t *aExpatName, nsIAtom **aPrefix,
|
||||||
nameStart = (uriEnd + 1);
|
nameStart = (uriEnd + 1);
|
||||||
if (nameEnd) {
|
if (nameEnd) {
|
||||||
const char16_t *prefixStart = nameEnd + 1;
|
const char16_t *prefixStart = nameEnd + 1;
|
||||||
*aPrefix = NS_Atomize(Substring(prefixStart, pos)).take();
|
*aPrefix = NS_AtomizeMainThread(Substring(prefixStart, pos)).take();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nameEnd = pos;
|
nameEnd = pos;
|
||||||
|
|
@ -3049,7 +3050,7 @@ nsContentUtils::SplitExpatName(const char16_t *aExpatName, nsIAtom **aPrefix,
|
||||||
nameEnd = pos;
|
nameEnd = pos;
|
||||||
*aPrefix = nullptr;
|
*aPrefix = nullptr;
|
||||||
}
|
}
|
||||||
*aLocalName = NS_Atomize(Substring(nameStart, nameEnd)).take();
|
*aLocalName = NS_AtomizeMainThread(Substring(nameStart, nameEnd)).take();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
@ -3887,7 +3888,8 @@ nsContentUtils::GetEventMessageAndAtom(const nsAString& aName,
|
||||||
}
|
}
|
||||||
|
|
||||||
*aEventMessage = eUnidentifiedEvent;
|
*aEventMessage = eUnidentifiedEvent;
|
||||||
nsCOMPtr<nsIAtom> atom = NS_Atomize(NS_LITERAL_STRING("on") + aName);
|
nsCOMPtr<nsIAtom> atom =
|
||||||
|
NS_AtomizeMainThread(NS_LITERAL_STRING("on") + aName);
|
||||||
sUserDefinedEvents->AppendObject(atom);
|
sUserDefinedEvents->AppendObject(atom);
|
||||||
mapping.mAtom = atom;
|
mapping.mAtom = atom;
|
||||||
mapping.mMessage = eUnidentifiedEvent;
|
mapping.mMessage = eUnidentifiedEvent;
|
||||||
|
|
@ -3920,7 +3922,7 @@ nsContentUtils::GetEventMessageAndAtomForListener(const nsAString& aName,
|
||||||
if (mapping.mMaybeSpecialSVGorSMILEvent) {
|
if (mapping.mMaybeSpecialSVGorSMILEvent) {
|
||||||
// Try the atom version so that we should get the right message for
|
// Try the atom version so that we should get the right message for
|
||||||
// SVG/SMIL.
|
// SVG/SMIL.
|
||||||
atom = NS_Atomize(NS_LITERAL_STRING("on") + aName);
|
atom = NS_AtomizeMainThread(NS_LITERAL_STRING("on") + aName);
|
||||||
msg = GetEventMessage(atom);
|
msg = GetEventMessage(atom);
|
||||||
} else {
|
} else {
|
||||||
atom = mapping.mAtom;
|
atom = mapping.mAtom;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue