Bug 244475, avoid some shared buffer overhead and an extra allocation/copy when looking up attribute name atoms. r+sr=bzbarsky.

This commit is contained in:
bryner%brianryner.com 2004-05-24 06:10:52 +00:00
Родитель 0eed25c9b6
Коммит 523004daf8
2 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -803,7 +803,7 @@ HTMLContentSink::AddAttributes(const nsIParserNode& aNode,
return NS_OK;
}
nsAutoString k;
nsCAutoString k;
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
// The attributes are on the parser node in the order they came in in the
@ -818,7 +818,9 @@ HTMLContentSink::AddAttributes(const nsIParserNode& aNode,
for (PRInt32 i = ac - 1; i >= 0; i--) {
// Get lower-cased key
const nsAString& key = aNode.GetKeyAt(i);
k.Assign(key);
// Copy up-front to avoid shared-buffer overhead (and convert to UTF-8
// at the same time since that's what the atom table uses).
CopyUTF16toUTF8(key, k);
ToLowerCase(k);
nsCOMPtr<nsIAtom> keyAtom = do_GetAtom(k);

Просмотреть файл

@ -864,7 +864,7 @@ nsHTMLFragmentContentSink::AddAttributes(const nsIParserNode& aNode,
return NS_OK;
}
nsAutoString k;
nsCAutoString k;
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
// The attributes are on the parser node in the order they came in in the
@ -879,7 +879,9 @@ nsHTMLFragmentContentSink::AddAttributes(const nsIParserNode& aNode,
for (PRInt32 i = ac - 1; i >= 0; i--) {
// Get lower-cased key
const nsAString& key = aNode.GetKeyAt(i);
k.Assign(key);
// Copy up-front to avoid shared-buffer overhead (and convert to UTF-8
// at the same time since that's what the atom table uses).
CopyUTF16toUTF8(key, k);
ToLowerCase(k);
nsCOMPtr<nsIAtom> keyAtom = do_GetAtom(k);