Bug 1530369 - part 1 - don't needlessly write characters when skipping; r=ckerschb
authorNathan Froyd <froydnj@mozilla.com>
Mon, 25 Feb 2019 13:58:54 -0500
changeset 518897 938c2d1dbf3f53f7d4f8d06572937bf3ef9aa22d
parent 518896 2bcc26b5ecf765c47aea275da83a39b3aa8ea4a8
child 518898 689ee6c61e51f80e65756006c3764778828bfaa5
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 1 - don't needlessly write characters when skipping; r=ckerschb The skipWhiteSpace* family of functions write the characters they're skipping, only to truncate the string after skipping. This appending is needless work, so let's skip it.
dom/security/PolicyTokenizer.h
--- a/dom/security/PolicyTokenizer.h
+++ b/dom/security/PolicyTokenizer.h
@@ -40,25 +40,25 @@ class PolicyTokenizer {
  private:
   PolicyTokenizer(const char16_t* aStart, const char16_t* aEnd);
   ~PolicyTokenizer();
 
   inline bool atEnd() { return mCurChar >= mEndChar; }
 
   inline void skipWhiteSpace() {
     while (mCurChar < mEndChar && nsContentUtils::IsHTMLWhitespace(*mCurChar)) {
-      mCurToken.Append(*mCurChar++);
+      mCurChar++;
     }
     mCurToken.Truncate();
   }
 
   inline void skipWhiteSpaceAndSemicolon() {
     while (mCurChar < mEndChar &&
            (*mCurChar == ';' || nsContentUtils::IsHTMLWhitespace(*mCurChar))) {
-      mCurToken.Append(*mCurChar++);
+      mCurChar++;
     }
     mCurToken.Truncate();
   }
 
   inline bool accept(char16_t aChar) {
     NS_ASSERTION(mCurChar < mEndChar, "Trying to dereference mEndChar");
     if (*mCurChar == aChar) {
       mCurToken.Append(*mCurChar++);