Bug 1025184 - Make ConstTwoByteChars a Range. r=jandem
authorTooru Fujisawa <arai_a@mac.com>
Tue, 10 Feb 2015 12:52:18 +0900
changeset 228395 cb655f416527aa70f67fcf8992cf814f843af311
parent 228394 8b46de889f4c191321ad2728f466be51f4054edd
child 228396 3023f9390942ce022a214b224f18cb01bb24daa0
push id28261
push userryanvm@gmail.com
push dateTue, 10 Feb 2015 21:03:20 +0000
treeherdermozilla-central@ee093ca70666 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1025184
milestone38.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 1025184 - Make ConstTwoByteChars a Range. r=jandem
dom/json/nsJSON.cpp
js/public/CharacterEncoding.h
js/src/jsfun.cpp
--- a/dom/json/nsJSON.cpp
+++ b/dom/json/nsJSON.cpp
@@ -531,17 +531,17 @@ nsJSONListener::OnStopRequest(nsIRequest
     rv = ProcessBytes(nullptr, 0);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   JS::Rooted<JS::Value> reviver(mCx, JS::NullValue()), value(mCx);
 
   JS::ConstTwoByteChars chars(reinterpret_cast<const char16_t*>(mBufferedChars.Elements()),
                               mBufferedChars.Length());
-  bool ok = JS_ParseJSONWithReviver(mCx, chars.get(),
+  bool ok = JS_ParseJSONWithReviver(mCx, chars.start().get(),
                                       uint32_t(mBufferedChars.Length()),
                                       reviver, &value);
 
   *mRootVal = value;
   mBufferedChars.TruncateLength(0);
   return ok ? NS_OK : NS_ERROR_FAILURE;
 }
 
--- a/js/public/CharacterEncoding.h
+++ b/js/public/CharacterEncoding.h
@@ -146,27 +146,23 @@ class TwoByteCharsZ : public mozilla::Ra
     using Base::operator=;
 };
 
 typedef mozilla::RangedPtr<const char16_t> ConstCharPtr;
 
 /*
  * Like TwoByteChars, but the chars are const.
  */
-class ConstTwoByteChars : public mozilla::RangedPtr<const char16_t>
+class ConstTwoByteChars : public mozilla::Range<const char16_t>
 {
+    typedef mozilla::Range<const char16_t> Base;
+
   public:
-    ConstTwoByteChars(const ConstTwoByteChars &s) : ConstCharPtr(s) {}
-    MOZ_IMPLICIT ConstTwoByteChars(const mozilla::RangedPtr<const char16_t> &s) : ConstCharPtr(s) {}
-    ConstTwoByteChars(const char16_t *s, size_t len) : ConstCharPtr(s, len) {}
-    ConstTwoByteChars(const char16_t *pos, const char16_t *start, size_t len)
-      : ConstCharPtr(pos, start, len)
-    {}
-
-    using ConstCharPtr::operator=;
+    ConstTwoByteChars() : Base() {}
+    ConstTwoByteChars(const char16_t *aChars, size_t aLength) : Base(aChars, aLength) {}
 };
 
 /*
  * Convert a 2-byte character sequence to "ISO-Latin-1". This works by
  * truncating each 2-byte pair in the sequence to a 1-byte pair. If the source
  * contains any UTF-16 extension characters, then this may give invalid Latin1
  * output. The returned string is zero terminated. The returned string or the
  * returned string's |start()| must be freed with JS_free or js_free,
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -1815,17 +1815,17 @@ FunctionConstructor(JSContext *cx, unsig
 
         /*
          * Initialize a tokenstream that reads from the given string.  No
          * StrictModeGetter is needed because this TokenStream won't report any
          * strict mode errors.  Any strict mode errors which might be reported
          * here (duplicate argument names, etc.) will be detected when we
          * compile the function body.
          */
-        TokenStream ts(cx, options, collected_args.get(), args_length,
+        TokenStream ts(cx, options, collected_args.start().get(), args_length,
                        /* strictModeGetter = */ nullptr);
         bool yieldIsValidName = ts.versionNumber() < JSVERSION_1_7 && !isStarGenerator;
 
         /* The argument string may be empty or contain no tokens. */
         TokenKind tt;
         if (!ts.getToken(&tt))
             return false;
         if (tt != TOK_EOF) {