Bug 1388789 - replace hex strings with static arrays; r=froydnj
authorTom Tromey <tom@tromey.com>
Fri, 01 Sep 2017 06:25:11 -0600
changeset 431517 c118b2a8f1b12e7354b8fe284b489310bc717d99
parent 431516 ec3f626df9d1fde0095c0df104a7f4e7863ca5ff
child 431518 ed7a9616664877b2a543deb84090201a0543b2d5
push id7784
push userryanvm@gmail.com
push dateThu, 21 Sep 2017 00:40:13 +0000
treeherdermozilla-beta@efff4f307675 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1388789
milestone57.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 1388789 - replace hex strings with static arrays; r=froydnj nsTextFormatter used nsAutoString for arrays of hex digits; but this didn't seem to provide any benefit. MozReview-Commit-ID: EYHtnAzJL8h
xpcom/string/nsTextFormatter.cpp
--- a/xpcom/string/nsTextFormatter.cpp
+++ b/xpcom/string/nsTextFormatter.cpp
@@ -828,21 +828,18 @@ dosprintf(SprintfStateStr* aState, const
     int64_t ll;
     double d;
     const char* s;
     const char16_t* S;
     int* ip;
   } u;
   char16_t space = ' ';
 
-  nsAutoString hex;
-  hex.AssignLiteral("0123456789abcdef");
-
-  nsAutoString HEX;
-  HEX.AssignLiteral("0123456789ABCDEF");
+  static const char16_t hex[] = u"0123456789abcdef";
+  static char16_t HEX[] = u"0123456789ABCDEF";
 
   const char16_t* hexp;
   int rv, i;
   struct NumArgState* nas = nullptr;
   struct NumArgState  nasArray[NAS_DEFAULT_NUM];
 
 
   /*
@@ -976,17 +973,17 @@ dosprintf(SprintfStateStr* aState, const
       c = *aFmt++;
       if (c == 'l') {
         type = NumArgState::INT64;
         c = *aFmt++;
       }
     }
 
     /* format */
-    hexp = hex.get();
+    hexp = hex;
     switch (c) {
       case 'd':
       case 'i':                               /* decimal/integer */
         radix = 10;
         goto fetch_and_convert;
 
       case 'o':                               /* octal */
         radix = 8;
@@ -1000,17 +997,17 @@ dosprintf(SprintfStateStr* aState, const
 
       case 'x':                               /* unsigned hex */
         radix = 16;
         type |= 1;
         goto fetch_and_convert;
 
       case 'X':                               /* unsigned HEX */
         radix = 16;
-        hexp = HEX.get();
+        hexp = HEX;
         type |= 1;
         goto fetch_and_convert;
 
         fetch_and_convert:
         switch (type) {
           case NumArgState::INT16:
             u.l = va_arg(aAp, int);
             if (u.l < 0) {