Bug 977445 - Remove unused JSContext parameter from BooleanToStringBuffer() and friends. r=luke
authorChris Peterson <cpeterson@mozilla.com>
Sun, 23 Feb 2014 17:59:18 -0800
changeset 182134 56f74fcba1d667d98bcdb4d1e6cdf472bcee8d98
parent 182133 61834b158c735d050c6dd1f925ff5a70d0974d5f
child 182135 ae1369b970a51a04bc85ba55fc2947841bdacac9
push idunknown
push userunknown
push dateunknown
reviewersluke
bugs977445
milestone30.0a1
Bug 977445 - Remove unused JSContext parameter from BooleanToStringBuffer() and friends. r=luke
js/src/jsarray.cpp
js/src/jsbool.cpp
js/src/jsbool.h
js/src/jsboolinlines.h
js/src/json.cpp
js/src/vm/StringBuffer.cpp
js/src/vm/StringBuffer.h
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -993,17 +993,17 @@ ArrayJoinKernel(JSContext *cx, Separator
 
             if (elem.isString()) {
                 if (!sb.append(elem.toString()))
                     return false;
             } else if (elem.isNumber()) {
                 if (!NumberValueToStringBuffer(cx, elem, sb))
                     return false;
             } else if (elem.isBoolean()) {
-                if (!BooleanToStringBuffer(cx, elem.toBoolean(), sb))
+                if (!BooleanToStringBuffer(elem.toBoolean(), sb))
                     return false;
             } else if (elem.isObject()) {
                 /*
                  * Object stringifying could modify the initialized length or make
                  * the array sparse. Delegate it to a separate loop to keep this
                  * one tight.
                  */
                 break;
@@ -1426,17 +1426,17 @@ NumDigitsBase10(uint32_t n)
      * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
      */
     uint32_t log2 = CeilingLog2(n);
     uint32_t t = log2 * 1233 >> 12;
     return t - (n < powersOf10[t]) + 1;
 }
 
 static inline bool
-CompareLexicographicInt32(JSContext *cx, const Value &a, const Value &b, bool *lessOrEqualp)
+CompareLexicographicInt32(const Value &a, const Value &b, bool *lessOrEqualp)
 {
     int32_t aint = a.toInt32();
     int32_t bint = b.toInt32();
 
     /*
      * If both numbers are equal ... trivial
      * If only one of both is negative --> arithmetic comparison as char code
      * of '-' is always less than any other digit
@@ -1499,23 +1499,18 @@ struct SortComparatorStrings
 
     bool operator()(const Value &a, const Value &b, bool *lessOrEqualp) {
         return CompareStringValues(cx, a, b, lessOrEqualp);
     }
 };
 
 struct SortComparatorLexicographicInt32
 {
-    JSContext   *const cx;
-
-    SortComparatorLexicographicInt32(JSContext *cx)
-      : cx(cx) {}
-
     bool operator()(const Value &a, const Value &b, bool *lessOrEqualp) {
-        return CompareLexicographicInt32(cx, a, b, lessOrEqualp);
+        return CompareLexicographicInt32(a, b, lessOrEqualp);
     }
 };
 
 struct StringifiedElement
 {
     size_t charsBegin;
     size_t charsEnd;
     size_t elementIndex;
@@ -1935,17 +1930,17 @@ js::array_sort(JSContext *cx, unsigned a
              */
             if (allStrings) {
                 JS_ALWAYS_TRUE(vec.resize(n * 2));
                 if (!MergeSort(vec.begin(), n, vec.begin() + n, SortComparatorStrings(cx)))
                     return false;
             } else if (allInts) {
                 JS_ALWAYS_TRUE(vec.resize(n * 2));
                 if (!MergeSort(vec.begin(), n, vec.begin() + n,
-                               SortComparatorLexicographicInt32(cx))) {
+                               SortComparatorLexicographicInt32())) {
                     return false;
                 }
             } else {
                 if (!SortLexicographically(cx, &vec, n))
                     return false;
             }
         } else {
             ComparatorMatchResult comp = MatchNumericComparator(cx, fval);
--- a/js/src/jsbool.cpp
+++ b/js/src/jsbool.cpp
@@ -48,17 +48,17 @@ MOZ_ALWAYS_INLINE bool
 bool_toSource_impl(JSContext *cx, CallArgs args)
 {
     HandleValue thisv = args.thisv();
     JS_ASSERT(IsBoolean(thisv));
 
     bool b = thisv.isBoolean() ? thisv.toBoolean() : thisv.toObject().as<BooleanObject>().unbox();
 
     StringBuffer sb(cx);
-    if (!sb.append("(new Boolean(") || !BooleanToStringBuffer(cx, b, sb) || !sb.append("))"))
+    if (!sb.append("(new Boolean(") || !BooleanToStringBuffer(b, sb) || !sb.append("))"))
         return false;
 
     JSString *str = sb.finishString();
     if (!str)
         return false;
     args.rval().setString(str);
     return true;
 }
@@ -191,14 +191,14 @@ js::ToBooleanSlow(HandleValue v)
     return !EmulatesUndefined(&v.toObject());
 }
 
 /*
  * This slow path is only ever taken for proxies wrapping Boolean objects
  * The only caller of the fast path, JSON's PreprocessValue, ensures that.
  */
 bool
-js::BooleanGetPrimitiveValueSlow(HandleObject wrappedBool, JSContext *cx)
+js::BooleanGetPrimitiveValueSlow(HandleObject wrappedBool)
 {
     JSObject *obj = wrappedBool->as<ProxyObject>().target();
     JS_ASSERT(obj);
     return obj->as<BooleanObject>().unbox();
 }
--- a/js/src/jsbool.h
+++ b/js/src/jsbool.h
@@ -17,13 +17,13 @@ extern JSObject *
 js_InitBooleanClass(JSContext *cx, js::HandleObject obj);
 
 extern JSString *
 js_BooleanToString(js::ExclusiveContext *cx, bool b);
 
 namespace js {
 
 inline bool
-BooleanGetPrimitiveValue(HandleObject obj, JSContext *cx);
+BooleanGetPrimitiveValue(HandleObject obj);
 
 } /* namespace js */
 
 #endif /* jsbool_h */
--- a/js/src/jsboolinlines.h
+++ b/js/src/jsboolinlines.h
@@ -10,25 +10,25 @@
 #include "jsbool.h"
 
 #include "vm/BooleanObject.h"
 #include "vm/WrapperObject.h"
 
 namespace js {
 
 bool
-BooleanGetPrimitiveValueSlow(HandleObject, JSContext *);
+BooleanGetPrimitiveValueSlow(HandleObject);
 
 inline bool
-BooleanGetPrimitiveValue(HandleObject obj, JSContext *cx)
+BooleanGetPrimitiveValue(HandleObject obj)
 {
     if (obj->is<BooleanObject>())
         return obj->as<BooleanObject>().unbox();
 
-    return BooleanGetPrimitiveValueSlow(obj, cx);
+    return BooleanGetPrimitiveValueSlow(obj);
 }
 
 inline bool
 EmulatesUndefined(JSObject *obj)
 {
     JSObject *actual = MOZ_LIKELY(!obj->is<WrapperObject>()) ? obj : UncheckedUnwrap(obj);
     return actual->getClass()->emulatesUndefined();
 }
--- a/js/src/json.cpp
+++ b/js/src/json.cpp
@@ -245,17 +245,17 @@ PreprocessValue(JSContext *cx, HandleObj
                 return false;
             vp.set(NumberValue(d));
         } else if (ObjectClassIs(obj, ESClass_String, cx)) {
             JSString *str = ToStringSlow<CanGC>(cx, vp);
             if (!str)
                 return false;
             vp.set(StringValue(str));
         } else if (ObjectClassIs(obj, ESClass_Boolean, cx)) {
-            vp.setBoolean(BooleanGetPrimitiveValue(obj, cx));
+            vp.setBoolean(BooleanGetPrimitiveValue(obj));
         }
     }
 
     return true;
 }
 
 /*
  * Determines whether a value which has passed by ES5 150.2.3 Str steps 1-4's
--- a/js/src/vm/StringBuffer.cpp
+++ b/js/src/vm/StringBuffer.cpp
@@ -87,14 +87,14 @@ js::ValueToStringBufferSlow(JSContext *c
     if (!ToPrimitive(cx, JSTYPE_STRING, &v))
         return false;
 
     if (v.isString())
         return sb.append(v.toString());
     if (v.isNumber())
         return NumberValueToStringBuffer(cx, v, sb);
     if (v.isBoolean())
-        return BooleanToStringBuffer(cx, v.toBoolean(), sb);
+        return BooleanToStringBuffer(v.toBoolean(), sb);
     if (v.isNull())
         return sb.append(cx->names().null);
     JS_ASSERT(v.isUndefined());
     return sb.append(cx->names().undefined);
 }
--- a/js/src/vm/StringBuffer.h
+++ b/js/src/vm/StringBuffer.h
@@ -136,16 +136,16 @@ ValueToStringBuffer(JSContext *cx, const
     if (v.isString())
         return sb.append(v.toString());
 
     return ValueToStringBufferSlow(cx, v, sb);
 }
 
 /* ES5 9.8 ToString for booleans, appending the result to the string buffer. */
 inline bool
-BooleanToStringBuffer(JSContext *cx, bool b, StringBuffer &sb)
+BooleanToStringBuffer(bool b, StringBuffer &sb)
 {
     return b ? sb.append("true") : sb.append("false");
 }
 
 }  /* namespace js */
 
 #endif /* vm_StringBuffer_h */