Bug 1603406 - Part 12: Unused String functions. r=mgaudet
authorAndré Bargull <andre.bargull@gmail.com>
Thu, 12 Dec 2019 16:48:58 +0000
changeset 506880 679db0122024db925b0c2b20f86b83999e52d2c4
parent 506879 4d34599c5b9973980ff9128c8b65045414314bb0
child 506881 6e2fbd64ae49a57d10775375a3df8912c0e8ab32
push id36913
push useropoprus@mozilla.com
push dateFri, 13 Dec 2019 16:53:24 +0000
treeherdermozilla-central@1ed684598bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmgaudet
bugs1603406
milestone73.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 1603406 - Part 12: Unused String functions. r=mgaudet Depends on D56900 Differential Revision: https://phabricator.services.mozilla.com/D56901
js/src/vm/StringType.cpp
js/src/vm/StringType.h
--- a/js/src/vm/StringType.cpp
+++ b/js/src/vm/StringType.cpp
@@ -1307,48 +1307,16 @@ void StaticStrings::trace(JSTracer* trc)
   }
 
   /* This may mark some strings more than once, but so be it. */
   for (uint32_t i = 0; i < INT_STATIC_LIMIT; i++) {
     TraceStaticString(trc, intStaticTable[i], "int-static-string");
   }
 }
 
-template <typename CharT>
-/* static */
-bool StaticStrings::isStatic(const CharT* chars, size_t length) {
-  switch (length) {
-    case 1: {
-      char16_t c = chars[0];
-      return c < UNIT_STATIC_LIMIT;
-    }
-    case 2:
-      return fitsInSmallChar(chars[0]) && fitsInSmallChar(chars[1]);
-    case 3:
-      if ('1' <= chars[0] && chars[0] <= '9' && '0' <= chars[1] &&
-          chars[1] <= '9' && '0' <= chars[2] && chars[2] <= '9') {
-        int i =
-            (chars[0] - '0') * 100 + (chars[1] - '0') * 10 + (chars[2] - '0');
-
-        return unsigned(i) < INT_STATIC_LIMIT;
-      }
-      return false;
-    default:
-      return false;
-  }
-}
-
-/* static */
-bool StaticStrings::isStatic(JSAtom* atom) {
-  AutoCheckCannotGC nogc;
-  return atom->hasLatin1Chars()
-             ? isStatic(atom->latin1Chars(nogc), atom->length())
-             : isStatic(atom->twoByteChars(nogc), atom->length());
-}
-
 bool AutoStableStringChars::init(JSContext* cx, JSString* s) {
   RootedLinearString linearString(cx, s->ensureLinear(cx));
   if (!linearString) {
     return false;
   }
 
   MOZ_ASSERT(state_ == Uninitialized);
 
--- a/js/src/vm/StringType.h
+++ b/js/src/vm/StringType.h
@@ -1285,17 +1285,16 @@ class StaticStrings {
   }
 
   /* May not return atom, returns null on (reported) failure. */
   inline JSLinearString* getUnitStringForElement(JSContext* cx, JSString* str,
                                                  size_t index);
 
   template <typename CharT>
   static bool isStatic(const CharT* chars, size_t len);
-  static bool isStatic(JSAtom* atom);
 
   /* Return null if no static atom exists for the given (chars, length). */
   template <typename Chars>
   MOZ_ALWAYS_INLINE JSAtom* lookup(Chars chars, size_t length) {
     static_assert(std::is_same<Chars, const Latin1Char*>::value ||
                       std::is_same<Chars, const char16_t*>::value ||
                       std::is_same<Chars, LittleEndianChars>::value,
                   "for understandability, |chars| must be one of a few "
@@ -1381,20 +1380,16 @@ class StaticStrings {
   static const SmallCharArray toSmallCharArray;
 
   MOZ_ALWAYS_INLINE JSAtom* getLength2(char16_t c1, char16_t c2) {
     MOZ_ASSERT(fitsInSmallChar(c1));
     MOZ_ASSERT(fitsInSmallChar(c2));
     size_t index = (size_t(toSmallCharArray[c1]) << 6) + toSmallCharArray[c2];
     return length2StaticTable[index];
   }
-  JSAtom* getLength2(uint32_t u) {
-    MOZ_ASSERT(u < 100);
-    return getLength2('0' + u / 10, '0' + u % 10);
-  }
 };
 
 /*
  * Represents an atomized string which does not contain an index (that is, an
  * unsigned 32-bit value).  Thus for any PropertyName propname,
  * ToString(ToUint32(propname)) never equals propname.
  *
  * To more concretely illustrate the utility of PropertyName, consider that it