summaryrefslogtreecommitdiffstats
path: root/parser/html/nsHtml5Highlighter.cpp
diff options
context:
space:
mode:
authorwin7-7 <win7-7@users.noreply.github.com>2019-07-05 21:58:21 +0300
committerwin7-7 <win7-7@users.noreply.github.com>2019-07-05 21:58:21 +0300
commit7c5a0db237c7a43136ee3cdc6cfb0663778d9e2c (patch)
tree9cd5a806763b73bed3fef3d599f32b525f4c0d7a /parser/html/nsHtml5Highlighter.cpp
parent0e54a032624b4ce23a959454047bfd504a734cc0 (diff)
downloadUXP-7c5a0db237c7a43136ee3cdc6cfb0663778d9e2c.tar
UXP-7c5a0db237c7a43136ee3cdc6cfb0663778d9e2c.tar.gz
UXP-7c5a0db237c7a43136ee3cdc6cfb0663778d9e2c.tar.lz
UXP-7c5a0db237c7a43136ee3cdc6cfb0663778d9e2c.tar.xz
UXP-7c5a0db237c7a43136ee3cdc6cfb0663778d9e2c.zip
Introduce a new non-heap-allocated type for holding nsStringBuffer* in the HTML parser.
An innerHTML setter profile shows about 10% of the time being spent under nsHtml5HtmlAttributes::clear, mostly deleting nsStrings.
Diffstat (limited to 'parser/html/nsHtml5Highlighter.cpp')
-rw-r--r--parser/html/nsHtml5Highlighter.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/parser/html/nsHtml5Highlighter.cpp b/parser/html/nsHtml5Highlighter.cpp
index 259803ee1..23cdf7d84 100644
--- a/parser/html/nsHtml5Highlighter.cpp
+++ b/parser/html/nsHtml5Highlighter.cpp
@@ -91,7 +91,7 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle)
if (length > INT32_MAX) {
length = INT32_MAX;
}
- AppendCharacters(aTitle.get(), 0, (int32_t)length);
+ AppendCharacters(aTitle.BeginReading(), 0, (int32_t)length);
Pop(); // title
Push(nsGkAtoms::link, nsHtml5ViewSourceUtils::NewLinkAttributes());
@@ -105,7 +105,7 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle)
Push(nsGkAtoms::body, nsHtml5ViewSourceUtils::NewBodyAttributes());
nsHtml5HtmlAttributes* preAttrs = new nsHtml5HtmlAttributes(0);
- nsString* preId = new nsString(NS_LITERAL_STRING("line1"));
+ nsHtml5String preId = nsHtml5Portability::newStringFromLiteral("line1");
preAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, preId, -1);
Push(nsGkAtoms::pre, preAttrs);
@@ -618,7 +618,7 @@ nsHtml5Highlighter::FlushOps()
void
nsHtml5Highlighter::MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName,
- nsString* aValue)
+ nsHtml5String aValue)
{
if (!(nsHtml5AttributeName::ATTR_HREF == aName ||
nsHtml5AttributeName::ATTR_SRC == aName ||
@@ -630,7 +630,7 @@ nsHtml5Highlighter::MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName,
nsHtml5AttributeName::ATTR_DEFINITIONURL == aName)) {
return;
}
- AddViewSourceHref(*aValue);
+ AddViewSourceHref(aValue);
}
void
@@ -717,10 +717,10 @@ nsHtml5Highlighter::AddClass(const char16_t* aClass)
}
void
-nsHtml5Highlighter::AddViewSourceHref(const nsString& aValue)
+nsHtml5Highlighter::AddViewSourceHref(nsHtml5String aValue)
{
char16_t* bufferCopy = new char16_t[aValue.Length() + 1];
- memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t));
+ aValue.CopyToBuffer(bufferCopy);
bufferCopy[aValue.Length()] = 0;
mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceHref,
@@ -730,14 +730,14 @@ nsHtml5Highlighter::AddViewSourceHref(const nsString& aValue)
}
void
-nsHtml5Highlighter::AddBase(const nsString& aValue)
+nsHtml5Highlighter::AddBase(nsHtml5String aValue)
{
if(mSeenBase) {
return;
}
mSeenBase = true;
char16_t* bufferCopy = new char16_t[aValue.Length() + 1];
- memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t));
+ aValue.CopyToBuffer(bufferCopy);
bufferCopy[aValue.Length()] = 0;
mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceBase,