summaryrefslogtreecommitdiff
path: root/parser/html/nsHtml5HtmlAttributes.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
commitefe62d1d7e54f99d2c6467ba97c835c37811b0ce (patch)
tree9cd5a806763b73bed3fef3d599f32b525f4c0d7a /parser/html/nsHtml5HtmlAttributes.cpp
parent18fdb6141caa440d27a016f686aa1099eff0c8fb (diff)
downloaduxp-efe62d1d7e54f99d2c6467ba97c835c37811b0ce.tar.gz
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/nsHtml5HtmlAttributes.cpp')
-rw-r--r--parser/html/nsHtml5HtmlAttributes.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/parser/html/nsHtml5HtmlAttributes.cpp b/parser/html/nsHtml5HtmlAttributes.cpp
index d515f381d0..62b9ae2b25 100644
--- a/parser/html/nsHtml5HtmlAttributes.cpp
+++ b/parser/html/nsHtml5HtmlAttributes.cpp
@@ -30,7 +30,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
-#include "nsString.h"
+#include "nsHtml5String.h"
#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
@@ -58,11 +58,11 @@
nsHtml5HtmlAttributes* nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES = nullptr;
nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(int32_t mode)
- : mode(mode),
- length(0),
- names(jArray<nsHtml5AttributeName*,int32_t>::newJArray(8)),
- values(jArray<nsString*,int32_t>::newJArray(8)),
- lines(jArray<int32_t,int32_t>::newJArray(8))
+ : mode(mode)
+ , length(0)
+ , names(jArray<nsHtml5AttributeName*, int32_t>::newJArray(8))
+ , values(jArray<nsHtml5String, int32_t>::newJArray(8))
+ , lines(jArray<int32_t, int32_t>::newJArray(8))
{
MOZ_COUNT_CTOR(nsHtml5HtmlAttributes);
}
@@ -85,7 +85,7 @@ nsHtml5HtmlAttributes::getIndex(nsHtml5AttributeName* name)
return -1;
}
-nsString*
+nsHtml5String
nsHtml5HtmlAttributes::getValue(nsHtml5AttributeName* name)
{
int32_t index = getIndex(name);
@@ -123,7 +123,7 @@ nsHtml5HtmlAttributes::getPrefixNoBoundsCheck(int32_t index)
return names[index]->getPrefix(mode);
}
-nsString*
+nsHtml5String
nsHtml5HtmlAttributes::getValueNoBoundsCheck(int32_t index)
{
MOZ_ASSERT(index < length && index >= 0, "Index out of bounds");
@@ -145,14 +145,17 @@ nsHtml5HtmlAttributes::getLineNoBoundsCheck(int32_t index)
}
void
-nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsString* value, int32_t line)
+nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name,
+ nsHtml5String value,
+ int32_t line)
{
if (names.length == length) {
int32_t newLen = length << 1;
jArray<nsHtml5AttributeName*,int32_t> newNames = jArray<nsHtml5AttributeName*,int32_t>::newJArray(newLen);
nsHtml5ArrayCopy::arraycopy(names, newNames, names.length);
names = newNames;
- jArray<nsString*,int32_t> newValues = jArray<nsString*,int32_t>::newJArray(newLen);
+ jArray<nsHtml5String, int32_t> newValues =
+ jArray<nsHtml5String, int32_t>::newJArray(newLen);
nsHtml5ArrayCopy::arraycopy(values, newValues, values.length);
values = newValues;
jArray<int32_t,int32_t> newLines = jArray<int32_t,int32_t>::newJArray(newLen);
@@ -171,7 +174,7 @@ nsHtml5HtmlAttributes::clear(int32_t m)
for (int32_t i = 0; i < length; i++) {
names[i]->release();
names[i] = nullptr;
- nsHtml5Portability::releaseString(values[i]);
+ values[i].Release();
values[i] = nullptr;
}
length = 0;
@@ -181,7 +184,7 @@ nsHtml5HtmlAttributes::clear(int32_t m)
void
nsHtml5HtmlAttributes::releaseValue(int32_t i)
{
- nsHtml5Portability::releaseString(values[i]);
+ values[i].Release();
}
void