Bug 1530369 - part 2 - bulk-append characters in generateNextToken; r=ckerschb
authorNathan Froyd <froydnj@mozilla.com>
Mon, 25 Feb 2019 13:58:53 -0500
changeset 518898 689ee6c61e51f80e65756006c3764778828bfaa5
parent 518897 938c2d1dbf3f53f7d4f8d06572937bf3ef9aa22d
child 518899 c95f0d583ed590b69f1e10bfbc1c466706f272d1
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1530369
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530369 - part 2 - bulk-append characters in generateNextToken; r=ckerschb Instead of appending each individual charater, we can delay the append until after the loop, which saves on function calls.
dom/security/PolicyTokenizer.cpp
--- a/dom/security/PolicyTokenizer.cpp
+++ b/dom/security/PolicyTokenizer.cpp
@@ -22,19 +22,24 @@ PolicyTokenizer::PolicyTokenizer(const c
 }
 
 PolicyTokenizer::~PolicyTokenizer() {
   POLICYTOKENIZERLOG(("PolicyTokenizer::~PolicyTokenizer"));
 }
 
 void PolicyTokenizer::generateNextToken() {
   skipWhiteSpaceAndSemicolon();
+  MOZ_ASSERT(mCurToken.Length() == 0);
+  const char16_t* const start = mCurChar;
   while (!atEnd() && !nsContentUtils::IsHTMLWhitespace(*mCurChar) &&
          *mCurChar != SEMICOL) {
-    mCurToken.Append(*mCurChar++);
+    mCurChar++;
+  }
+  if (start != mCurChar) {
+    mCurToken.Append(start, mCurChar - start);
   }
   POLICYTOKENIZERLOG(("PolicyTokenizer::generateNextToken: %s",
                       NS_ConvertUTF16toUTF8(mCurToken).get()));
 }
 
 void PolicyTokenizer::generateTokens(policyTokens& outTokens) {
   POLICYTOKENIZERLOG(("PolicyTokenizer::generateTokens"));