From 501e430b3480f1325f97bd3de838c1594742fa20 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Wed, 3 Nov 2004 19:44:59 +0000 Subject: [PATCH] Reduce string copying from nsGenericHTMLElement::GetHrefURIForAnchors (bug 267506). r+sr=jst. --- content/base/src/nsContentUtils.cpp | 7 ++----- content/html/content/src/nsGenericHTMLElement.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index ce55e286c1ce..8f71e5d2612e 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -1538,11 +1538,8 @@ nsContentUtils::NewURIWithDocumentCharset(nsIURI** aResult, nsIDocument* aDocument, nsIURI* aBaseURI) { - nsCAutoString originCharset; - if (aDocument) - originCharset = aDocument->GetDocumentCharacterSet(); - - return NS_NewURI(aResult, NS_ConvertUCS2toUTF8(aSpec), originCharset.get(), + return NS_NewURI(aResult, aSpec, + aDocument ? aDocument->GetDocumentCharacterSet().get() : nsnull, aBaseURI, sIOService); } diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 0db0201a5f1c..dc60afeb2586 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -1583,16 +1583,16 @@ nsGenericHTMLElement::GetHrefURIForAnchors(nsIURI** aURI) // nsHTMLStyleElement. // Get href= attribute (relative URI). - nsAutoString relURISpec; - if (NS_CONTENT_ATTR_HAS_VALUE == - GetAttr(kNameSpaceID_None, nsHTMLAtoms::href, relURISpec)) { + // We use the nsAttrValue's copy of the URI string to avoid copying. + const nsAttrValue* attr = mAttrsAndChildren.GetAttr(nsHTMLAtoms::href); + if (attr) { // Get base URI. nsCOMPtr baseURI = GetBaseURI(); // Get absolute URI. nsresult rv = nsContentUtils::NewURIWithDocumentCharset(aURI, - relURISpec, + attr->GetStringValue(), GetOwnerDoc(), baseURI); if (NS_FAILED(rv)) {