Bug 1453456 - Remove nsCRT::IsAscii(char16_t) in favor of mozilla::IsAscii. r=froydnj
authorJeff Walden <jwalden@mit.edu>
Mon, 25 Feb 2019 12:21:15 -0800
changeset 519528 e4565e7ddcb07bb6f4bc59623c821445d8e49069
parent 519527 603a46a1e921a1fae58fa168461935a42270c1f0
child 519529 18e52bd7c3adaa0e9bfae00942c935cb7568c054
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)
reviewersfroydnj
bugs1453456
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 1453456 - Remove nsCRT::IsAscii(char16_t) in favor of mozilla::IsAscii. r=froydnj
netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
xpcom/base/nsCRTGlue.h
xpcom/ds/nsCRT.h
--- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
+++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
@@ -15,16 +15,18 @@
 
 #include <algorithm>
 
 #ifdef DEBUG_BenB_Perf
 #  include "prtime.h"
 #  include "prinrval.h"
 #endif
 
+using mozilla::IsAscii;
+
 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) {
   return (nsCRT::IsAsciiSpace(aChar) || aChar == 0xA0 || aChar == 0x3000);
@@ -209,17 +211,17 @@ bool mozTXTToHTMLConv::FindURLStart(cons
       // These chars mark the start of the URL
       for (; i >= 0 && aInString[uint32_t(i)] != '>' &&
              aInString[uint32_t(i)] != '<' && aInString[uint32_t(i)] != '"' &&
              aInString[uint32_t(i)] != '\'' && aInString[uint32_t(i)] != '`' &&
              aInString[uint32_t(i)] != ',' && aInString[uint32_t(i)] != '{' &&
              aInString[uint32_t(i)] != '[' && aInString[uint32_t(i)] != '(' &&
              aInString[uint32_t(i)] != '|' && aInString[uint32_t(i)] != '\\' &&
              !IsSpace(aInString[uint32_t(i)]) &&
-             (!isEmail || nsCRT::IsAscii(aInString[uint32_t(i)])) &&
+             (!isEmail || IsAscii(aInString[uint32_t(i)])) &&
              (!isEmail || aInString[uint32_t(i)] != ')');
            i--)
         ;
       if (++i >= 0 && uint32_t(i) < pos &&
           (IsAsciiAlpha(aInString[uint32_t(i)]) ||
            IsAsciiDigit(aInString[uint32_t(i)]))) {
         start = uint32_t(i);
         return true;
@@ -265,17 +267,17 @@ bool mozTXTToHTMLConv::FindURLEnd(const 
             // Allow IPv6 adresses like http://[1080::8:800:200C:417A]/foo.
             (aInString[i] == '[' && i > 2 &&
              (aInString[i - 1] != '/' || aInString[i - 2] != '/')) ||
             IsSpace(aInString[i]))
           break;
         // Disallow non-ascii-characters for email.
         // Currently correct, but revisit later after standards changed.
         if (isEmail && (aInString[i] == '(' || aInString[i] == '\'' ||
-                        !nsCRT::IsAscii(aInString[i])))
+                        !IsAscii(aInString[i])))
           break;
         if (aInString[i] == '(') seenOpeningParenthesis = true;
         if (aInString[i] == '[') seenOpeningSquareBracket = true;
       }
       // These chars are allowed in the middle of the URL, but not at end.
       // Technically they are, but are used in normal text after the URL.
       while (--i > pos && (aInString[i] == '.' || aInString[i] == ',' ||
                            aInString[i] == ';' || aInString[i] == '!' ||
--- a/xpcom/base/nsCRTGlue.h
+++ b/xpcom/base/nsCRTGlue.h
@@ -88,18 +88,16 @@ inline char NS_ToUpper(char aChar) {
 
 inline char NS_ToLower(char aChar) {
   return (char)nsLowerUpperUtils::kUpper2Lower[(unsigned char)aChar];
 }
 
 bool NS_IsUpper(char aChar);
 bool NS_IsLower(char aChar);
 
-constexpr bool NS_IsAscii(char16_t aChar) { return (0x0080 > aChar); }
-
 constexpr bool NS_IsAscii(const char16_t* aString) {
   while (*aString) {
     if (0x0080 <= *aString) {
       return false;
     }
     aString++;
   }
   return true;
--- a/xpcom/ds/nsCRT.h
+++ b/xpcom/ds/nsCRT.h
@@ -84,17 +84,16 @@ class nsCRT {
   static int64_t atoll(const char* aStr);
 
   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 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);
   }