зеркало из https://github.com/mozilla/gecko-dev.git
Bug 231199: Make hashing of mapped-attributes be case sensitive to improve performance, and enable possible codesharing with xul and svg in the future.
r=peterv sr=jst
This commit is contained in:
Родитель
85b6ff86eb
Коммит
878604026e
|
@ -263,7 +263,7 @@ nsAttrValue::HashValue() const
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsAttrValue::EqualsIgnoreCase(const nsAttrValue& aOther) const
|
||||
nsAttrValue::Equals(const nsAttrValue& aOther) const
|
||||
{
|
||||
if (GetType() != aOther.GetType()) {
|
||||
return PR_FALSE;
|
||||
|
@ -272,8 +272,7 @@ nsAttrValue::EqualsIgnoreCase(const nsAttrValue& aOther) const
|
|||
switch(GetType()) {
|
||||
case eString:
|
||||
{
|
||||
return GetStringValue().Equals(aOther.GetStringValue(),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
return GetStringValue().Equals(aOther.GetStringValue());
|
||||
}
|
||||
case eHTMLValue:
|
||||
{
|
||||
|
@ -281,11 +280,7 @@ nsAttrValue::EqualsIgnoreCase(const nsAttrValue& aOther) const
|
|||
}
|
||||
case eAtom:
|
||||
{
|
||||
const char *class1, *class2;
|
||||
GetAtomValue()->GetUTF8String(&class1);
|
||||
aOther.GetAtomValue()->GetUTF8String(&class2);
|
||||
|
||||
return nsCRT::strcasecmp(class1, class2) == 0;
|
||||
return GetAtomValue() == aOther.GetAtomValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
nsIAtom* GetAtomValue() const;
|
||||
|
||||
PRUint32 HashValue() const;
|
||||
PRBool EqualsIgnoreCase(const nsAttrValue& aOther) const;
|
||||
PRBool Equals(const nsAttrValue& aOther) const;
|
||||
|
||||
enum Type {
|
||||
eString = 0,
|
||||
|
|
|
@ -133,8 +133,7 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
|||
|
||||
case HTMLUNIT_STRING:
|
||||
if (mValue.mString && aOther.mValue.mString) {
|
||||
return GetDependentString().Equals(aOther.GetDependentString(),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
return GetDependentString().Equals(aOther.GetDependentString());
|
||||
}
|
||||
// One of them is null. An == check will see if they are both null.
|
||||
return mValue.mString == aOther.mValue.mString;
|
||||
|
@ -154,9 +153,8 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
|||
|
||||
case HTMLUNIT_ATOMARRAY:
|
||||
{
|
||||
// Currently this isn't called (since atomarrays are never the value of
|
||||
// a mapped attribute) so it doesn't matter that it's slow.
|
||||
// It would be a lot simpler/faster if it was case sensitive though
|
||||
// For classlists we could be insensitive to order, however
|
||||
// classlists are never mapped attributes so they are never compared.
|
||||
|
||||
PRInt32 count = mValue.mAtomArray->Count();
|
||||
if (count != aOther.mValue.mAtomArray->Count()) {
|
||||
|
@ -165,17 +163,8 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
|||
|
||||
PRInt32 i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
const char *class1;
|
||||
mValue.mAtomArray->ObjectAt(i)->GetUTF8String(&class1);
|
||||
PRInt32 j;
|
||||
for (j = 0; j < count; ++j) {
|
||||
const char* class2;
|
||||
aOther.mValue.mAtomArray->ObjectAt(j)->GetUTF8String(&class2);
|
||||
if (nsCRT::strcasecmp(class1, class2) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == count) {
|
||||
if (mValue.mAtomArray->ObjectAt(i) !=
|
||||
aOther.mValue.mAtomArray->ObjectAt(i)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ nsMappedAttributes::Equals(const nsMappedAttributes* aOther) const
|
|||
PRUint32 i;
|
||||
for (i = 0; i < mAttrCount; ++i) {
|
||||
if (!Attrs()[i].mName.Equals(aOther->Attrs()[i].mName) ||
|
||||
!Attrs()[i].mValue.EqualsIgnoreCase(aOther->Attrs()[i].mValue)) {
|
||||
!Attrs()[i].mValue.Equals(aOther->Attrs()[i].mValue)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,8 +133,7 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
|||
|
||||
case HTMLUNIT_STRING:
|
||||
if (mValue.mString && aOther.mValue.mString) {
|
||||
return GetDependentString().Equals(aOther.GetDependentString(),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
return GetDependentString().Equals(aOther.GetDependentString());
|
||||
}
|
||||
// One of them is null. An == check will see if they are both null.
|
||||
return mValue.mString == aOther.mValue.mString;
|
||||
|
@ -154,9 +153,8 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
|||
|
||||
case HTMLUNIT_ATOMARRAY:
|
||||
{
|
||||
// Currently this isn't called (since atomarrays are never the value of
|
||||
// a mapped attribute) so it doesn't matter that it's slow.
|
||||
// It would be a lot simpler/faster if it was case sensitive though
|
||||
// For classlists we could be insensitive to order, however
|
||||
// classlists are never mapped attributes so they are never compared.
|
||||
|
||||
PRInt32 count = mValue.mAtomArray->Count();
|
||||
if (count != aOther.mValue.mAtomArray->Count()) {
|
||||
|
@ -165,17 +163,8 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
|||
|
||||
PRInt32 i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
const char *class1;
|
||||
mValue.mAtomArray->ObjectAt(i)->GetUTF8String(&class1);
|
||||
PRInt32 j;
|
||||
for (j = 0; j < count; ++j) {
|
||||
const char* class2;
|
||||
aOther.mValue.mAtomArray->ObjectAt(j)->GetUTF8String(&class2);
|
||||
if (nsCRT::strcasecmp(class1, class2) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == count) {
|
||||
if (mValue.mAtomArray->ObjectAt(i) !=
|
||||
aOther.mValue.mAtomArray->ObjectAt(i)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче