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
--- 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) {