Bug 1453456 - Replace nsCRT::IsAscii{Alpha,Digit} with mfbt/TextUtils.h versions. r=froydnj
authorJeff Walden <jwalden@mit.edu>
Thu, 12 Apr 2018 20:19:30 -0700
changeset 413377 c530019cba7727ddcdbfd9d052c24fb113056e7b
parent 413376 69fbc1090788f798834bac5bad41fc8a3ff33d59
child 413378 89bb0e170cc0e04aabac80388294af7fcf34b2bd
push id33845
push usercsabou@mozilla.com
push dateSat, 14 Apr 2018 23:37:33 +0000
treeherdermozilla-central@008f977fc4ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1453456
milestone61.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 1453456 - Replace nsCRT::IsAscii{Alpha,Digit} with mfbt/TextUtils.h versions. r=froydnj
docshell/base/nsDefaultURIFixup.cpp
dom/base/ResponsiveImageSelector.cpp
dom/html/HTMLInputElement.cpp
dom/html/input/SingleLineTextInputTypes.cpp
dom/mathml/nsMathMLElement.cpp
dom/quota/ActorsParent.cpp
dom/webbrowserpersist/nsWebBrowserPersist.cpp
js/src/ctypes/CTypes.cpp
layout/mathml/nsMathMLmpaddedFrame.cpp
mfbt/TextUtils.h
mfbt/tests/TestTextUtils.cpp
netwerk/base/nsStandardURL.cpp
netwerk/base/nsURLHelper.cpp
netwerk/base/nsURLParsers.cpp
netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
xpcom/base/nsCRTGlue.h
xpcom/ds/nsCRT.h
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -2,32 +2,32 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsIProtocolHandler.h"
-#include "nsCRT.h"
 
 #include "nsIFile.h"
 #include <algorithm>
 
 #ifdef MOZ_TOOLKIT_SEARCH
 #include "nsIBrowserSearchService.h"
 #endif
 
 #include "nsIURIFixup.h"
 #include "nsIURIMutator.h"
 #include "nsDefaultURIFixup.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/ipc/IPCStreamUtils.h"
 #include "mozilla/ipc/URIUtils.h"
+#include "mozilla/TextUtils.h"
 #include "mozilla/Tokenizer.h"
 #include "mozilla/Unused.h"
 #include "nsIObserverService.h"
 #include "nsXULAppAPI.h"
 
 // Used to check if external protocol schemes are usable
 #include "nsCExternalHandlerService.h"
 #include "nsIExternalProtocolService.h"
@@ -741,18 +741,18 @@ nsDefaultURIFixup::PossiblyHostPortUrl(c
   aUrl.EndReading(iterEnd);
   nsACString::const_iterator iter = iterBegin;
 
   while (iter != iterEnd) {
     uint32_t chunkSize = 0;
     // Parse a chunk of the address
     while (iter != iterEnd &&
            (*iter == '-' ||
-            nsCRT::IsAsciiAlpha(*iter) ||
-            nsCRT::IsAsciiDigit(*iter))) {
+            IsAsciiAlpha(*iter) ||
+            IsAsciiDigit(*iter))) {
       ++chunkSize;
       ++iter;
     }
     if (chunkSize == 0 || iter == iterEnd) {
       return false;
     }
     if (*iter == ':') {
       // Go onto checking the for the digits
@@ -770,17 +770,17 @@ nsDefaultURIFixup::PossiblyHostPortUrl(c
   }
   ++iter;
 
   // Count the number of digits after the colon and before the
   // next forward slash (or end of string)
 
   uint32_t digitCount = 0;
   while (iter != iterEnd && digitCount <= 5) {
-    if (nsCRT::IsAsciiDigit(*iter)) {
+    if (IsAsciiDigit(*iter)) {
       digitCount++;
     } else if (*iter == '/') {
       break;
     } else {
       // Whatever it is, it ain't a port!
       return false;
     }
     ++iter;
@@ -849,17 +849,17 @@ nsDefaultURIFixup::KeywordURIFixup(const
   while (iter != iterEnd) {
     if (pos >= 1 && foundRSBrackets == 0) {
       if (!(lastLSBracketLoc == 0 &&
             (*iter == ':' ||
              *iter == '.' ||
              *iter == ']' ||
              (*iter >= 'a' && *iter <= 'f') ||
              (*iter >= 'A' && *iter <= 'F') ||
-             nsCRT::IsAsciiDigit(*iter)))) {
+             IsAsciiDigit(*iter)))) {
         looksLikeIpv6 = false;
       }
     }
 
     // If we're at the end of the string or this is the first slash,
     // check if the thing before the slash looks like ipv4:
     if ((iterEnd - iter == 1 ||
          (lastSlashLoc == uint32_t(kNotFound) && *iter == '/')) &&
@@ -895,19 +895,19 @@ nsDefaultURIFixup::KeywordURIFixup(const
                firstQuoteLoc == uint32_t(kNotFound)) {
       firstQuoteLoc = pos;
     } else if (*iter == '[') {
       lastLSBracketLoc = pos;
     } else if (*iter == ']') {
       foundRSBrackets++;
     } else if (*iter == '/') {
       lastSlashLoc = pos;
-    } else if (nsCRT::IsAsciiAlpha(*iter)) {
+    } else if (IsAsciiAlpha(*iter)) {
       hasAsciiAlpha = true;
-    } else if (nsCRT::IsAsciiDigit(*iter)) {
+    } else if (IsAsciiDigit(*iter)) {
       ++foundDigits;
     }
 
     pos++;
     iter++;
   }
 
   if (lastLSBracketLoc > 0 || foundRSBrackets != 1) {
--- a/dom/base/ResponsiveImageSelector.cpp
+++ b/dom/base/ResponsiveImageSelector.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/ResponsiveImageSelector.h"
 #include "mozilla/ServoStyleSetInlines.h"
+#include "mozilla/TextUtils.h"
 #include "nsIURI.h"
 #include "nsIDocument.h"
 #include "nsContentUtils.h"
 #include "nsPresContext.h"
 
 #include "nsCSSParser.h"
 #include "nsCSSProps.h"
 
@@ -50,47 +51,47 @@ ParseFloat(const nsAString& aString, dou
   if (iter == end) {
     return false;
   }
 
   if (*iter == char16_t('-') && ++iter == end) {
     return false;
   }
 
-  if (nsCRT::IsAsciiDigit(*iter)) {
-    for (; iter != end && nsCRT::IsAsciiDigit(*iter) ; ++iter);
+  if (IsAsciiDigit(*iter)) {
+    for (; iter != end && IsAsciiDigit(*iter) ; ++iter);
   } else if (*iter == char16_t('.')) {
     // Do nothing, jumps to fraction part
   } else {
     return false;
   }
 
   // Fraction
   if (*iter == char16_t('.')) {
     ++iter;
-    if (iter == end || !nsCRT::IsAsciiDigit(*iter)) {
+    if (iter == end || !IsAsciiDigit(*iter)) {
       // U+002E FULL STOP character (.) must be followed by one or more ASCII digits
       return false;
     }
 
-    for (; iter != end && nsCRT::IsAsciiDigit(*iter) ; ++iter);
+    for (; iter != end && IsAsciiDigit(*iter) ; ++iter);
   }
 
   if (iter != end && (*iter == char16_t('e') || *iter == char16_t('E'))) {
     ++iter;
     if (*iter == char16_t('-') || *iter == char16_t('+')) {
       ++iter;
     }
 
-    if (iter == end || !nsCRT::IsAsciiDigit(*iter)) {
+    if (iter == end || !IsAsciiDigit(*iter)) {
       // Should have one or more ASCII digits
       return false;
     }
 
-    for (; iter != end && nsCRT::IsAsciiDigit(*iter) ; ++iter);
+    for (; iter != end && IsAsciiDigit(*iter) ; ++iter);
   }
 
   if (iter != end) {
     return false;
   }
 
   nsresult rv;
   aDouble = PromiseFlatString(aString).ToDouble(&rv);
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -99,16 +99,17 @@
 #include "nsContentUtils.h"
 #include "mozilla/dom/DirectionalityUtils.h"
 #include "nsRadioVisitor.h"
 #include "nsTextEditorState.h"
 
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/MathAlgorithms.h"
+#include "mozilla/TextUtils.h"
 
 #include "nsIIDNService.h"
 
 #include <limits>
 
 #include "nsIColorPicker.h"
 #include "nsIStringEnumerator.h"
 #include "HTMLSplitOnSpacesTokenizer.h"
@@ -5043,17 +5044,17 @@ HTMLInputElement::SanitizeValue(nsAStrin
 
 bool HTMLInputElement::IsValidSimpleColor(const nsAString& aValue) const
 {
   if (aValue.Length() != 7 || aValue.First() != '#') {
     return false;
   }
 
   for (int i = 1; i < 7; ++i) {
-    if (!nsCRT::IsAsciiDigit(aValue[i]) &&
+    if (!IsAsciiDigit(aValue[i]) &&
         !(aValue[i] >= 'a' && aValue[i] <= 'f') &&
         !(aValue[i] >= 'A' && aValue[i] <= 'F')) {
       return false;
     }
   }
   return true;
 }
 
@@ -5351,17 +5352,17 @@ HTMLInputElement::NumberOfDaysInMonth(ui
 /* static */ bool
 HTMLInputElement::DigitSubStringToNumber(const nsAString& aStr,
                                          uint32_t aStart, uint32_t aLen,
                                          uint32_t* aRetVal)
 {
   MOZ_ASSERT(aStr.Length() > (aStart + aLen - 1));
 
   for (uint32_t offset = 0; offset < aLen; ++offset) {
-    if (!NS_IsAsciiDigit(aStr[aStart + offset])) {
+    if (!IsAsciiDigit(aStr[aStart + offset])) {
       return false;
     }
   }
 
   nsresult ec;
   *aRetVal = static_cast<uint32_t>(PromiseFlatString(Substring(aStr, aStart, aLen)).ToInteger(&ec));
 
   return NS_SUCCEEDED(ec);
--- a/dom/html/input/SingleLineTextInputTypes.cpp
+++ b/dom/html/input/SingleLineTextInputTypes.cpp
@@ -3,24 +3,28 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SingleLineTextInputTypes.h"
 
 #include "mozilla/dom/HTMLInputElement.h"
 #include "mozilla/dom/BindingDeclarations.h"
+#include "mozilla/TextUtils.h"
 #include "HTMLSplitOnSpacesTokenizer.h"
 #include "nsContentUtils.h"
 #include "nsCRTGlue.h"
 #include "nsIIDNService.h"
 #include "nsIIOService.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 
+using mozilla::IsAsciiAlpha;
+using mozilla::IsAsciiDigit;
+
 bool
 SingleLineTextInputTypeBase::IsMutable() const
 {
   return !mInputElement->IsDisabled() &&
          !mInputElement->HasAttr(kNameSpaceID_None, nsGkAtoms::readonly);
 }
 
 bool
@@ -218,17 +222,17 @@ EmailInputType::IsValidEmailAddress(cons
   uint32_t length = value.Length();
   uint32_t i = 0;
 
   // Parsing the username.
   for (; i < atPos; ++i) {
     char16_t c = value[i];
 
     // The username characters have to be in this list to be valid.
-    if (!(nsCRT::IsAsciiAlpha(c) || nsCRT::IsAsciiDigit(c) ||
+    if (!(IsAsciiAlpha(c) || IsAsciiDigit(c) ||
           c == '.' || c == '!' || c == '#' || c == '$' || c == '%' ||
           c == '&' || c == '\''|| c == '*' || c == '+' || c == '-' ||
           c == '/' || c == '=' || c == '?' || c == '^' || c == '_' ||
           c == '`' || c == '{' || c == '|' || c == '}' || c == '~' )) {
       return false;
     }
   }
 
@@ -249,17 +253,17 @@ EmailInputType::IsValidEmailAddress(cons
       if (value[i-1] == '.' || value[i-1] == '-') {
         return false;
       }
     } else if (c == '-'){
       // A dash can't follow a dot.
       if (value[i-1] == '.') {
         return false;
       }
-    } else if (!(nsCRT::IsAsciiAlpha(c) || nsCRT::IsAsciiDigit(c) ||
+    } else if (!(IsAsciiAlpha(c) || IsAsciiDigit(c) ||
                  c == '-')) {
       // The domain characters have to be in this list to be valid.
       return false;
     }
   }
 
   return true;
 }
--- a/dom/mathml/nsMathMLElement.cpp
+++ b/dom/mathml/nsMathMLElement.cpp
@@ -4,19 +4,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #include "nsMathMLElement.h"
 #include "base/compiler_specific.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/FontPropertyTypes.h"
+#include "mozilla/TextUtils.h"
 #include "nsGkAtoms.h"
 #include "nsITableCellLayout.h" // for MAX_COLSPAN / MAX_ROWSPAN
-#include "nsCRT.h"
 #include "nsLayoutStylesheetCache.h"
 #include "nsCSSValue.h"
 #include "nsCSSParser.h"
 #include "nsMappedAttributes.h"
 #include "nsStyleConsts.h"
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
@@ -416,17 +416,17 @@ nsMathMLElement::ParseNumericValue(const
     if (gotDot && c == '.') {
       if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
         ReportLengthParseError(aString, aDocument);
       }
       return false;  // two dots encountered
     }
     else if (c == '.')
       gotDot = true;
-    else if (!nsCRT::IsAsciiDigit(c)) {
+    else if (!IsAsciiDigit(c)) {
       str.Right(unit, stringLength - i);
       // some authors leave blanks before the unit, but that shouldn't
       // be allowed, so don't CompressWhitespace on 'unit'.
       break;
     }
     number.Append(c);
   }
 
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -38,16 +38,17 @@
 #include "mozilla/dom/quota/PQuotaUsageRequestParent.h"
 #include "mozilla/ipc/BackgroundParent.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
+#include "mozilla/TextUtils.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/Unused.h"
 #include "mozStorageCID.h"
 #include "mozStorageHelper.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsComponentManagerUtils.h"
 #include "nsAboutProtocolUtils.h"
 #include "nsCharSeparatedTokenizer.h"
@@ -8328,17 +8329,17 @@ OriginParser::HandleToken(const nsDepend
     case eExpectingAppIdOrScheme: {
       if (aToken.IsEmpty()) {
         QM_WARNING("Expected an app id or scheme (not an empty string)!");
 
         mError = true;
         return;
       }
 
-      if (NS_IsAsciiDigit(aToken.First())) {
+      if (IsAsciiDigit(aToken.First())) {
         // nsDependentCSubstring doesn't provice ToInteger()
         nsCString token(aToken);
 
         nsresult rv;
         uint32_t appId = token.ToInteger(&rv);
         if (NS_SUCCEEDED(rv)) {
           mAppId = appId;
           mState = eExpectingInMozBrowser;
@@ -8489,17 +8490,17 @@ OriginParser::HandleToken(const nsDepend
 
         mState =
           mTokenizer.hasMoreTokens() ? eExpectingEmptyTokenOrPathnameComponent
                                      : eComplete;
 
         return;
       }
 
-      if (aToken.Length() == 1 && NS_IsAsciiAlpha(aToken.First())) {
+      if (aToken.Length() == 1 && IsAsciiAlpha(aToken.First())) {
         mMaybeDriveLetter = true;
 
         mPathnameComponents.AppendElement(aToken);
 
         mState =
           mTokenizer.hasMoreTokens() ? eExpectingEmptyTokenOrPathnameComponent
                                      : eComplete;
 
--- a/dom/webbrowserpersist/nsWebBrowserPersist.cpp
+++ b/dom/webbrowserpersist/nsWebBrowserPersist.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/TextUtils.h"
 
 #include "nspr.h"
 
 #include "nsIFileStreams.h"       // New Necko file streams
 #include <algorithm>
 
 #include "nsAutoPtr.h"
 #include "nsNetCID.h"
@@ -25,17 +26,16 @@
 #include "nsIHttpChannelInternal.h"
 #include "nsIEncodedChannel.h"
 #include "nsIUploadChannel.h"
 #include "nsICacheInfoChannel.h"
 #include "nsIFileChannel.h"
 #include "nsEscape.h"
 #include "nsUnicharUtils.h"
 #include "nsIStringEnumerator.h"
-#include "nsCRT.h"
 #include "nsContentCID.h"
 #include "nsStreamUtils.h"
 
 #include "nsCExternalHandlerService.h"
 
 #include "nsIURL.h"
 #include "nsIFileURL.h"
 #include "nsIURIMutator.h"
@@ -2137,17 +2137,17 @@ nsWebBrowserPersist::MakeFilenameFromURI
         {
             // Unescape the file name (GetFileName escapes it)
             NS_UnescapeURL(nameFromURL);
             uint32_t nameLength = 0;
             const char *p = nameFromURL.get();
             for (;*p && *p != ';' && *p != '?' && *p != '#' && *p != '.'
                  ;p++)
             {
-                if (nsCRT::IsAsciiAlpha(*p) || nsCRT::IsAsciiDigit(*p)
+                if (IsAsciiAlpha(*p) || IsAsciiDigit(*p)
                     || *p == '.' || *p == '-' ||  *p == '_' || (*p == ' '))
                 {
                     fileName.Append(char16_t(*p));
                     if (++nameLength == kDefaultMaxFilenameLength)
                     {
                         // Note:
                         // There is no point going any further since it will be
                         // truncated in CalculateUniqueFilename anyway.
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -44,16 +44,17 @@
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 
 #include "vm/JSObject-inl.h"
 
 using namespace std;
 
 using mozilla::IsAsciiAlpha;
+using mozilla::IsAsciiDigit;
 
 using JS::AutoCheckCannotGC;
 
 namespace js {
 namespace ctypes {
 
 template <typename CharT>
 size_t
@@ -2935,27 +2936,28 @@ StringToInteger(JSContext* cx, CharT* cp
     base = 16;
   }
 
   // Scan the string left to right and build the number,
   // checking for valid characters 0 - 9, a - f, A - F and overflow.
   IntegerType i = 0;
   while (cp != end) {
     char16_t c = *cp++;
-    if (c >= '0' && c <= '9')
-      c -= '0';
+    uint8_t digit;
+    if (IsAsciiDigit(c))
+      digit = c - '0';
     else if (base == 16 && c >= 'a' && c <= 'f')
-      c = c - 'a' + 10;
+      digit = c - 'a' + 10;
     else if (base == 16 && c >= 'A' && c <= 'F')
-      c = c - 'A' + 10;
+      digit = c - 'A' + 10;
     else
       return false;
 
     IntegerType ii = i;
-    i = ii * base + sign * c;
+    i = ii * base + sign * digit;
     if (i / base != ii) {
       *overflow = true;
       return false;
     }
   }
 
   *result = i;
   return true;
--- a/layout/mathml/nsMathMLmpaddedFrame.cpp
+++ b/layout/mathml/nsMathMLmpaddedFrame.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #include "nsMathMLmpaddedFrame.h"
 #include "nsMathMLElement.h"
 #include "mozilla/gfx/2D.h"
+#include "mozilla/TextUtils.h"
 #include <algorithm>
 
 //
 // <mpadded> -- adjust space around content - implementation
 //
 
 #define NS_MATHML_SIGN_INVALID           -1 // if the attribute is not there
 #define NS_MATHML_SIGN_UNSPECIFIED        0
@@ -155,17 +156,17 @@ nsMathMLmpaddedFrame::ParseAttribute(nsS
     if (gotDot && c == '.') {
       // error - two dots encountered
       aSign = NS_MATHML_SIGN_INVALID;
       return false;
     }
 
     if (c == '.')
       gotDot = true;
-    else if (!nsCRT::IsAsciiDigit(c)) {
+    else if (!IsAsciiDigit(c)) {
       break;
     }
     number.Append(c);
   }
 
   // catch error if we didn't enter the loop above... we could simply initialize
   // floatValue = 1, to cater for cases such as width="height", but that wouldn't
   // be in line with the spec which requires an explicit number
--- a/mfbt/TextUtils.h
+++ b/mfbt/TextUtils.h
@@ -76,28 +76,41 @@ IsAsciiUppercaseAlpha(Char aChar)
 template<typename Char>
 constexpr bool
 IsAsciiAlpha(Char aChar)
 {
   return IsAsciiLowercaseAlpha(aChar) || IsAsciiUppercaseAlpha(aChar);
 }
 
 /**
+ * Returns true iff |aChar| matches [0-9].
+ *
+ * This function is basically what you thought isdigit was, except its behavior
+ * doesn't depend on the user's current locale.
+ */
+template<typename Char>
+constexpr bool
+IsAsciiDigit(Char aChar)
+{
+  using UnsignedChar = typename detail::MakeUnsignedChar<Char>::Type;
+  auto uc = static_cast<UnsignedChar>(aChar);
+  return '0' <= uc && uc <= '9';
+}
+
+/**
  * Returns true iff |aChar| matches [a-zA-Z0-9].
  *
  * This function is basically what you thought isalnum was, except its behavior
  * doesn't depend on the user's current locale.
  */
 template<typename Char>
 constexpr bool
 IsAsciiAlphanumeric(Char aChar)
 {
-  using UnsignedChar = typename detail::MakeUnsignedChar<Char>::Type;
-  auto uc = static_cast<UnsignedChar>(aChar);
-  return ('0' <= uc && uc <= '9') || IsAsciiAlpha(uc);
+  return IsAsciiDigit(aChar) || IsAsciiAlpha(aChar);
 }
 
 /**
  * Converts an ASCII alphanumeric digit [0-9a-zA-Z] to number as if in base-36.
  * (This function therefore works for decimal, hexadecimal, etc.).
  */
 template<typename Char>
 uint8_t
--- a/mfbt/tests/TestTextUtils.cpp
+++ b/mfbt/tests/TestTextUtils.cpp
@@ -5,16 +5,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Assertions.h"
 #include "mozilla/TextUtils.h"
 
 using mozilla::AsciiAlphanumericToNumber;
 using mozilla::IsAsciiAlpha;
 using mozilla::IsAsciiAlphanumeric;
+using mozilla::IsAsciiDigit;
 using mozilla::IsAsciiLowercaseAlpha;
 using mozilla::IsAsciiUppercaseAlpha;
 
 static void
 TestIsAsciiAlpha()
 {
   // char
 
@@ -604,17 +605,114 @@ TestAsciiAlphanumericToNumber()
   MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U'u') == 30, "U'u' converts to 30");
   MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U'v') == 31, "U'v' converts to 31");
   MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U'w') == 32, "U'w' converts to 32");
   MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U'x') == 33, "U'x' converts to 33");
   MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U'y') == 34, "U'y' converts to 34");
   MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U'z') == 35, "U'z' converts to 35");
 }
 
+static void
+TestIsAsciiDigit()
+{
+  // char
+
+  static_assert(!IsAsciiDigit('/'), "'/' isn't an ASCII digit");
+  static_assert('/' == 0x2F, "'/' has value 0x2F");
+
+  static_assert('0' == 0x30, "'0' has value 0x30");
+  static_assert(IsAsciiDigit('0'), "'0' is an ASCII digit");
+  static_assert(IsAsciiDigit('1'), "'1' is an ASCII digit");
+  static_assert(IsAsciiDigit('5'), "'5' is an ASCII digit");
+  static_assert(IsAsciiDigit('8'), "'8' is an ASCII digit");
+  static_assert(IsAsciiDigit('9'), "'9' is an ASCII digit");
+
+  static_assert('9' == 0x39, "'9' has value 0x39");
+  static_assert(':' == 0x3A, "':' has value 0x3A");
+  static_assert(!IsAsciiDigit(':'), "':' isn't an ASCII digit");
+
+  static_assert(!IsAsciiDigit('@'), "'@' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('A'), "'A' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('B'), "'B' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('M'), "'M' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('Y'), "'Y' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('Z'), "'Z' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('['), "'[' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('`'), "'`' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('a'), "'a' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('b'), "'b' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('m'), "'m' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('y'), "'y' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('z'), "'z' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit('{'), "'{' isn't an ASCII digit");
+
+  // char16_t
+
+  static_assert(!IsAsciiDigit(u'/'), "u'/' isn't an ASCII digit");
+  static_assert(u'/' == 0x2F, "u'/' has value 0x2F");
+  static_assert(u'0' == 0x30, "u'0' has value 0x30");
+  static_assert(IsAsciiDigit(u'0'), "u'0' is an ASCII digit");
+  static_assert(IsAsciiDigit(u'1'), "u'1' is an ASCII digit");
+  static_assert(IsAsciiDigit(u'5'), "u'5' is an ASCII digit");
+  static_assert(IsAsciiDigit(u'8'), "u'8' is an ASCII digit");
+  static_assert(IsAsciiDigit(u'9'), "u'9' is an ASCII digit");
+
+  static_assert(u'9' == 0x39, "u'9' has value 0x39");
+  static_assert(u':' == 0x3A, "u':' has value 0x3A");
+  static_assert(!IsAsciiDigit(u':'), "u':' isn't an ASCII digit");
+
+  static_assert(!IsAsciiDigit(u'@'), "u'@' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'A'), "u'A' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'B'), "u'B' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'M'), "u'M' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'Y'), "u'Y' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'Z'), "u'Z' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'['), "u'[' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'`'), "u'`' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'a'), "u'a' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'b'), "u'b' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'm'), "u'm' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'y'), "u'y' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'z'), "u'z' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(u'{'), "u'{' isn't an ASCII digit");
+
+  // char32_t
+
+  static_assert(!IsAsciiDigit(U'/'), "U'/' isn't an ASCII digit");
+  static_assert(U'/' == 0x2F, "U'/' has value 0x2F");
+
+  static_assert(U'0' == 0x30, "U'0' has value 0x30");
+  static_assert(IsAsciiDigit(U'0'), "U'0' is an ASCII digit");
+  static_assert(IsAsciiDigit(U'1'), "U'1' is an ASCII digit");
+  static_assert(IsAsciiDigit(U'5'), "U'5' is an ASCII digit");
+  static_assert(IsAsciiDigit(U'8'), "U'8' is an ASCII digit");
+  static_assert(IsAsciiDigit(U'9'), "U'9' is an ASCII digit");
+
+  static_assert(U'9' == 0x39, "U'9' has value 0x39");
+  static_assert(U':' == 0x3A, "U':' has value 0x3A");
+  static_assert(!IsAsciiDigit(U':'), "U':' isn't an ASCII digit");
+
+  static_assert(!IsAsciiDigit(U'@'), "U'@' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'A'), "U'A' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'B'), "U'B' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'M'), "U'M' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'Y'), "U'Y' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'Z'), "U'Z' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'['), "U'[' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'`'), "U'`' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'a'), "U'a' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'b'), "U'b' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'm'), "U'm' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'y'), "U'y' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'z'), "U'z' isn't an ASCII digit");
+  static_assert(!IsAsciiDigit(U'{'), "U'{' isn't an ASCII digit");
+}
+
 int
 main()
 {
   TestIsAsciiAlpha();
   TestIsAsciiUppercaseAlpha();
   TestIsAsciiLowercaseAlpha();
   TestIsAsciiAlphanumeric();
   TestAsciiAlphanumericToNumber();
+  TestIsAsciiDigit();
 }
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -15,16 +15,17 @@
 #include "nsIObjectOutputStream.h"
 #include "nsIIDNService.h"
 #include "mozilla/Logging.h"
 #include "nsAutoPtr.h"
 #include "nsIURLParser.h"
 #include "nsNetCID.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/ipc/URIUtils.h"
+#include "mozilla/TextUtils.h"
 #include <algorithm>
 #include "nsContentUtils.h"
 #include "prprf.h"
 #include "nsReadableUtils.h"
 #include "mozilla/net/MozURL_ffi.h"
 
 
 //
@@ -908,17 +909,17 @@ nsStandardURL::BuildNormalizedSpec(const
 
     buf[i] = '\0';
 
     // https://url.spec.whatwg.org/#path-state (1.4.1.2)
     // https://url.spec.whatwg.org/#windows-drive-letter
     if (SegmentIs(buf, mScheme, "file")) {
         char* path = &buf[mPath.mPos];
         if (mPath.mLen >= 3 && path[0] == '/'
-            && nsCRT::IsAsciiAlpha(path[1])
+            && IsAsciiAlpha(path[1])
             && path[2] == '|') {
             buf[mPath.mPos + 2] = ':';
         }
     }
 
     if (mDirectory.mLen > 1) {
         netCoalesceFlags coalesceFlag = NET_COALESCE_NORMAL;
         if (SegmentIs(buf,mScheme,"ftp")) {
--- a/netwerk/base/nsURLHelper.cpp
+++ b/netwerk/base/nsURLHelper.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim:set ts=4 sw=4 sts=4 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/RangedPtr.h"
+#include "mozilla/TextUtils.h"
 
 #include <algorithm>
 #include <iterator>
 
 #include "nsASCIIMask.h"
 #include "nsURLHelper.h"
 #include "nsIFile.h"
 #include "nsIURLParser.h"
@@ -472,24 +473,20 @@ net_ResolveRelativePath(const nsACString
     result = path;
     return NS_OK;
 }
 
 //----------------------------------------------------------------------------
 // scheme fu
 //----------------------------------------------------------------------------
 
-static bool isAsciiAlpha(char c) {
-    return nsCRT::IsAsciiAlpha(c);
-}
-
 static bool
 net_IsValidSchemeChar(const char aChar)
 {
-    if (nsCRT::IsAsciiAlpha(aChar) || nsCRT::IsAsciiDigit(aChar) ||
+    if (IsAsciiAlpha(aChar) || IsAsciiDigit(aChar) ||
         aChar == '+' || aChar == '.' || aChar == '-') {
         return true;
     }
     return false;
 }
 
 /* Extract URI-Scheme if possible */
 nsresult
@@ -505,17 +502,17 @@ net_ExtractURLScheme(const nsACString &i
         if ((uint8_t) *start > 0x20) {
             break;
         }
         start++;
     }
 
     Tokenizer p(Substring(start, end), "\r\n\t");
     p.Record();
-    if (!p.CheckChar(isAsciiAlpha)) {
+    if (!p.CheckChar(IsAsciiAlpha)) {
         // First char must be alpha
         return NS_ERROR_MALFORMED_URI;
     }
 
     while (p.CheckChar(net_IsValidSchemeChar) || p.CheckWhite()) {
         // Skip valid scheme characters or \r\n\t
     }
 
@@ -528,23 +525,23 @@ net_ExtractURLScheme(const nsACString &i
     ToLowerCase(scheme);
     return NS_OK;
 }
 
 bool
 net_IsValidScheme(const char *scheme, uint32_t schemeLen)
 {
     // first char must be alpha
-    if (!nsCRT::IsAsciiAlpha(*scheme))
+    if (!IsAsciiAlpha(*scheme))
         return false;
 
     // nsCStrings may have embedded nulls -- reject those too
     for (; schemeLen; ++scheme, --schemeLen) {
-        if (!(nsCRT::IsAsciiAlpha(*scheme) ||
-              nsCRT::IsAsciiDigit(*scheme) ||
+        if (!(IsAsciiAlpha(*scheme) ||
+              IsAsciiDigit(*scheme) ||
               *scheme == '+' ||
               *scheme == '.' ||
               *scheme == '-'))
             return false;
     }
 
     return true;
 }
@@ -562,17 +559,17 @@ net_IsAbsoluteURL(const nsACString& uri)
             break;
         }
         start++;
     }
 
     Tokenizer p(Substring(start, end), "\r\n\t");
 
     // First char must be alpha
-    if (!p.CheckChar(isAsciiAlpha)) {
+    if (!p.CheckChar(IsAsciiAlpha)) {
         return false;
     }
 
     while (p.CheckChar(net_IsValidSchemeChar) || p.CheckWhite()) {
         // Skip valid scheme characters or \r\n\t
     }
     if (!p.CheckChar(':')) {
         return false;
--- a/netwerk/base/nsURLParsers.cpp
+++ b/netwerk/base/nsURLParsers.cpp
@@ -1,21 +1,21 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <string.h>
 
 #include "mozilla/RangedPtr.h"
+#include "mozilla/TextUtils.h"
 
 #include "nsURLParsers.h"
 #include "nsURLHelper.h"
 #include "nsString.h"
-#include "nsCRT.h"
 
 using namespace mozilla;
 
 //----------------------------------------------------------------------------
 
 static uint32_t
 CountConsecutiveSlashes(const char *str, int32_t len)
 {
@@ -382,17 +382,17 @@ nsNoAuthURLParser::ParseAfterScheme(cons
             if (specLen > 2) {
                 // looks like there is an authority section
 
                 // if the authority looks like a drive number then we
                 // really want to treat it as part of the path
                 // [a-zA-Z][:|]{/\}
                 // i.e one of:   c:   c:\foo  c:/foo  c|  c|\foo  c|/foo
                 if ((specLen > 3) && (spec[3] == ':' || spec[3] == '|') &&
-                    nsCRT::IsAsciiAlpha(spec[2]) &&
+                    IsAsciiAlpha(spec[2]) &&
                     ((specLen == 4) || (spec[4] == '/') || (spec[4] == '\\'))) {
                     pos = 1;
                     break;
                 }
                 // Ignore apparent authority; path is everything after it
                 for (p = spec + 2; p < spec + specLen; ++p) {
                     if (*p == '/' || *p == '?' || *p == '#')
                         break;
@@ -429,17 +429,17 @@ nsNoAuthURLParser::ParseFilePath(const c
 
     // look for a filepath consisting of only a drive number, which may or
     // may not have a leading slash.
     if (filepathLen > 1 && filepathLen < 4) {
         const char *end = filepath + filepathLen;
         const char *p = filepath;
         if (*p == '/')
             p++;
-        if ((end-p == 2) && (p[1]==':' || p[1]=='|') && nsCRT::IsAsciiAlpha(*p)) {
+        if ((end-p == 2) && (p[1]==':' || p[1]=='|') && IsAsciiAlpha(*p)) {
             // filepath = <drive-number>:
             SET_RESULT(directory, 0, filepathLen);
             SET_RESULT(basename, 0, -1);
             SET_RESULT(extension, 0, -1);
             return NS_OK;
         }
     }
 
--- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
+++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
@@ -1,28 +1,32 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/TextUtils.h"
 #include "mozTXTToHTMLConv.h"
 #include "nsNetUtil.h"
 #include "nsUnicharUtils.h"
 #include "nsCRT.h"
 #include "nsIExternalProtocolHandler.h"
 #include "nsIIOService.h"
 #include "nsIURI.h"
 
 #include <algorithm>
 
 #ifdef DEBUG_BenB_Perf
 #include "prtime.h"
 #include "prinrval.h"
 #endif
 
+using mozilla::IsAsciiAlpha;
+using mozilla::IsAsciiDigit;
+
 const double growthRate = 1.2;
 
 // Bug 183111, editor now replaces multiple spaces with leading
 // 0xA0's and a single ending space, so need to treat 0xA0's as spaces.
 // 0xA0 is the Latin1/Unicode character for "non-breaking space (nbsp)"
 // Also recognize the Japanese ideographic space 0x3000 as a space.
 static inline bool IsSpace(const char16_t aChar)
 {
@@ -214,24 +218,24 @@ mozTXTToHTMLConv::FindURLStart(const cha
     }
     else
       return false;
   }
   case freetext:
   {
     int32_t i = pos - 1;
     for (; i >= 0 && (
-         nsCRT::IsAsciiAlpha(aInString[uint32_t(i)]) ||
-         nsCRT::IsAsciiDigit(aInString[uint32_t(i)]) ||
+         IsAsciiAlpha(aInString[uint32_t(i)]) ||
+         IsAsciiDigit(aInString[uint32_t(i)]) ||
          aInString[uint32_t(i)] == '+' ||
          aInString[uint32_t(i)] == '-' ||
          aInString[uint32_t(i)] == '.'
          ); i--)
       ;
-    if (++i >= 0 && uint32_t(i) < pos && nsCRT::IsAsciiAlpha(aInString[uint32_t(i)]))
+    if (++i >= 0 && uint32_t(i) < pos && IsAsciiAlpha(aInString[uint32_t(i)]))
     {
       start = uint32_t(i);
       return true;
     }
     else
       return false;
   }
   case abbreviated:
@@ -252,18 +256,18 @@ mozTXTToHTMLConv::FindURLStart(const cha
              && (!isEmail || nsCRT::IsAscii(aInString[uint32_t(i)]))
          ; i--)
       ;
     if
       (
         ++i >= 0 && uint32_t(i) < pos
           &&
           (
-            nsCRT::IsAsciiAlpha(aInString[uint32_t(i)]) ||
-            nsCRT::IsAsciiDigit(aInString[uint32_t(i)])
+            IsAsciiAlpha(aInString[uint32_t(i)]) ||
+            IsAsciiDigit(aInString[uint32_t(i)])
           )
       )
     {
       start = uint32_t(i);
       return true;
     }
     else
       return false;
@@ -592,35 +596,35 @@ mozTXTToHTMLConv::ItMatchesDelimited(con
     return false;
 
   char16_t text0 = aInString[0];
   char16_t textAfterPos = aInString[aRepLen + (before == LT_IGNORE ? 0 : 1)];
 
   if
     (
       (before == LT_ALPHA
-        && !nsCRT::IsAsciiAlpha(text0)) ||
+        && !IsAsciiAlpha(text0)) ||
       (before == LT_DIGIT
-        && !nsCRT::IsAsciiDigit(text0)) ||
+        && !IsAsciiDigit(text0)) ||
       (before == LT_DELIMITER
         &&
         (
-          nsCRT::IsAsciiAlpha(text0) ||
-          nsCRT::IsAsciiDigit(text0) ||
+          IsAsciiAlpha(text0) ||
+          IsAsciiDigit(text0) ||
           text0 == *rep
         )) ||
       (after == LT_ALPHA
-        && !nsCRT::IsAsciiAlpha(textAfterPos)) ||
+        && !IsAsciiAlpha(textAfterPos)) ||
       (after == LT_DIGIT
-        && !nsCRT::IsAsciiDigit(textAfterPos)) ||
+        && !IsAsciiDigit(textAfterPos)) ||
       (after == LT_DELIMITER
         &&
         (
-          nsCRT::IsAsciiAlpha(textAfterPos) ||
-          nsCRT::IsAsciiDigit(textAfterPos) ||
+          IsAsciiAlpha(textAfterPos) ||
+          IsAsciiDigit(textAfterPos) ||
           textAfterPos == *rep
         )) ||
         !Substring(Substring(aInString, aInString+aInLength),
                    (before == LT_IGNORE ? 0 : 1),
                    aRepLen).Equals(Substring(rep, rep+aRepLen),
                                    nsCaseInsensitiveStringComparator())
     )
     return false;
@@ -939,39 +943,39 @@ mozTXTToHTMLConv::GlyphHit(const char16_
 
   // x^2  =>  x<sup>2</sup>,   also handle powers x^-2,  x^0.5
   // implement regular expression /[\dA-Za-z\)\]}]\^-?\d+(\.\d+)*[^\dA-Za-z]/
   if
     (
       text1 == '^'
       &&
       (
-        nsCRT::IsAsciiDigit(text0) || nsCRT::IsAsciiAlpha(text0) ||
+        IsAsciiDigit(text0) || IsAsciiAlpha(text0) ||
         text0 == ')' || text0 == ']' || text0 == '}'
       )
       &&
       (
-        (2 < aInLength && nsCRT::IsAsciiDigit(aInString[2])) ||
-        (3 < aInLength && aInString[2] == '-' && nsCRT::IsAsciiDigit(aInString[3]))
+        (2 < aInLength && IsAsciiDigit(aInString[2])) ||
+        (3 < aInLength && aInString[2] == '-' && IsAsciiDigit(aInString[3]))
       )
     )
   {
     // Find first non-digit
     int32_t delimPos = 3;  // skip "^" and first digit (or '-')
     for (; delimPos < aInLength
            &&
            (
-             nsCRT::IsAsciiDigit(aInString[delimPos]) ||
+             IsAsciiDigit(aInString[delimPos]) ||
              (aInString[delimPos] == '.' && delimPos + 1 < aInLength &&
-               nsCRT::IsAsciiDigit(aInString[delimPos + 1]))
+               IsAsciiDigit(aInString[delimPos + 1]))
            );
          delimPos++)
       ;
 
-    if (delimPos < aInLength && nsCRT::IsAsciiAlpha(aInString[delimPos]))
+    if (delimPos < aInLength && IsAsciiAlpha(aInString[delimPos]))
     {
       return false;
     }
 
     outputHTML.Truncate();
     outputHTML += text0;
     outputHTML.AppendLiteral(
       "<sup class=\"moz-txt-sup\">"
@@ -1043,17 +1047,17 @@ mozTXTToHTMLConv::CiteLevelTXT(const cha
 
        logLineStart is the position of "t" in this example
     */
     uint32_t i = logLineStart;
 
 #ifdef QUOTE_RECOGNITION_AGGRESSIVE
     for (; int32_t(i) < lineLength && IsSpace(line[i]); i++)
       ;
-    for (; int32_t(i) < lineLength && nsCRT::IsAsciiAlpha(line[i])
+    for (; int32_t(i) < lineLength && IsAsciiAlpha(line[i])
                                    && nsCRT::IsUpper(line[i])   ; i++)
       ;
     if (int32_t(i) < lineLength && (line[i] == '>' || line[i] == ']'))
 #else
     if (int32_t(i) < lineLength && line[i] == '>')
 #endif
     {
       i++;
--- a/xpcom/base/nsCRTGlue.h
+++ b/xpcom/base/nsCRTGlue.h
@@ -130,37 +130,24 @@ constexpr bool
 NS_ConstExprIsAscii(const char* aString, uint32_t aLength)
 {
   return aLength == 0 ? true :
     !NS_IsAscii(*aString) ? false :
     NS_ConstExprIsAscii(aString + 1, aLength - 1);
 }
 
 constexpr bool
-NS_IsAsciiAlpha(char16_t aChar)
-{
-  return (aChar >= 'A' && aChar <= 'Z') ||
-         (aChar >= 'a' && aChar <= 'z');
-}
-
-constexpr bool
 NS_IsAsciiWhitespace(char16_t aChar)
 {
   return aChar == ' ' ||
          aChar == '\r' ||
          aChar == '\n' ||
          aChar == '\t';
 }
 
-constexpr bool
-NS_IsAsciiDigit(char16_t aChar)
-{
-  return aChar >= '0' && aChar <= '9';
-}
-
 #ifndef XPCOM_GLUE_AVOID_NSPR
 void NS_MakeRandomString(char* aBuf, int32_t aBufLen);
 #endif
 
 #define FF '\f'
 #define TAB '\t'
 
 #define CRSTR "\015"
--- a/xpcom/ds/nsCRT.h
+++ b/xpcom/ds/nsCRT.h
@@ -91,18 +91,16 @@ public:
   static char ToUpper(char aChar) { return NS_ToUpper(aChar); }
   static char ToLower(char aChar) { return NS_ToLower(aChar); }
 
   static bool IsUpper(char aChar) { return NS_IsUpper(aChar); }
   static bool IsLower(char aChar) { return NS_IsLower(aChar); }
 
   static bool IsAscii(char16_t aChar) { return NS_IsAscii(aChar); }
   static bool IsAscii(const char16_t* aString) { return NS_IsAscii(aString); }
-  static bool IsAsciiAlpha(char16_t aChar) { return NS_IsAsciiAlpha(aChar); }
-  static bool IsAsciiDigit(char16_t aChar) { return NS_IsAsciiDigit(aChar); }
   static bool IsAsciiSpace(char16_t aChar) { return NS_IsAsciiWhitespace(aChar); }
   static bool IsAscii(const char* aString) { return NS_IsAscii(aString); }
   static bool IsAscii(const char* aString, uint32_t aLength)
   {
     return NS_IsAscii(aString, aLength);
   }
 };