Bug 537290 - Reduce uses of aNode.localName, namespaceURI in XPath generation [r=zeniko]

--HG--
extra : rebase_source : 7a3717de49f34007cc1a1d5405a98c2359120450
This commit is contained in:
Paul O’Shannessy 2010-01-05 10:50:22 -08:00
parent 1baff8a67f
commit 946fe7336d

View File

@ -3010,8 +3010,12 @@ let XPathHelper = {
if (!aNode.parentNode)
return "";
let prefix = this.namespacePrefixes[aNode.namespaceURI] || null;
let tag = (prefix ? prefix + ":" : "") + this.escapeName(aNode.localName);
// Access localName, namespaceURI just once per node since it's expensive.
let nNamespaceURI = aNode.namespaceURI;
let nLocalName = aNode.localName;
let prefix = this.namespacePrefixes[nNamespaceURI] || null;
let tag = (prefix ? prefix + ":" : "") + this.escapeName(nLocalName);
// stop once we've found a tag with an ID
if (aNode.id)
@ -3022,7 +3026,7 @@ let XPathHelper = {
let count = 0;
let nName = aNode.name || null;
for (let n = aNode; (n = n.previousSibling); )
if (n.localName == aNode.localName && n.namespaceURI == aNode.namespaceURI &&
if (n.localName == nLocalName && n.namespaceURI == nNamespaceURI &&
(!nName || n.name == nName))
count++;