Bug 1030183 - move NewStringCopy* definitions to avoid unified-build bustage (r=jandem)
authorLuke Wagner <luke@mozilla.com>
Wed, 25 Jun 2014 11:39:15 -0500
changeset 191041 b513f4a6913ab3c7ed291046d5889f1a20eecc57
parent 191040 6af628e72633f057148f6bfa59a6ebd181e67cdf
child 191042 4fb43d3e1db15c37b991f82f11c9780b92c804b3
push id8417
push userryanvm@gmail.com
push dateThu, 26 Jun 2014 21:15:47 +0000
treeherderb2g-inbound@3bef42144aab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1030183
milestone33.0a1
Bug 1030183 - move NewStringCopy* definitions to avoid unified-build bustage (r=jandem)
js/src/jsstr.cpp
js/src/jsstr.h
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -4502,58 +4502,18 @@ template JSFlatString *
 NewStringCopyN<NoGC>(ThreadSafeContext *cx, const jschar *s, size_t n);
 
 template JSFlatString *
 NewStringCopyN<CanGC>(ThreadSafeContext *cx, const Latin1Char *s, size_t n);
 
 template JSFlatString *
 NewStringCopyN<NoGC>(ThreadSafeContext *cx, const Latin1Char *s, size_t n);
 
-template <>
-JSFlatString *
-NewStringCopyN<CanGC>(ThreadSafeContext *cx, const char *s, size_t n)
-{
-    return NewStringCopyN<CanGC>(cx, reinterpret_cast<const Latin1Char *>(s), n);
-}
-
-template <>
-JSFlatString *
-NewStringCopyN<NoGC>(ThreadSafeContext *cx, const char *s, size_t n)
-{
-    return NewStringCopyN<NoGC>(cx, reinterpret_cast<const Latin1Char *>(s), n);
-}
-
 } /* namespace js */
 
-template <AllowGC allowGC>
-JSFlatString *
-js::NewStringCopyZ(ExclusiveContext *cx, const jschar *s)
-{
-    return NewStringCopyN<allowGC>(cx, s, js_strlen(s));
-}
-
-template JSFlatString *
-js::NewStringCopyZ<CanGC>(ExclusiveContext *cx, const jschar *s);
-
-template JSFlatString *
-js::NewStringCopyZ<NoGC>(ExclusiveContext *cx, const jschar *s);
-
-template <AllowGC allowGC>
-JSFlatString *
-js::NewStringCopyZ(ThreadSafeContext *cx, const char *s)
-{
-    return NewStringCopyN<allowGC>(cx, s, strlen(s));
-}
-
-template JSFlatString *
-js::NewStringCopyZ<CanGC>(ThreadSafeContext *cx, const char *s);
-
-template JSFlatString *
-js::NewStringCopyZ<NoGC>(ThreadSafeContext *cx, const char *s);
-
 const char *
 js_ValueToPrintable(JSContext *cx, const Value &vArg, JSAutoByteString *bytes, bool asSource)
 {
     RootedValue v(cx, vArg);
     JSString *str;
     if (asSource)
         str = ValueToSource(cx, v);
     else
--- a/js/src/jsstr.h
+++ b/js/src/jsstr.h
@@ -100,44 +100,76 @@ js_InitStringClass(JSContext *cx, js::Ha
 
 /*
  * Convert a value to a printable C string.
  */
 extern const char *
 js_ValueToPrintable(JSContext *cx, const js::Value &,
                     JSAutoByteString *bytes, bool asSource = false);
 
+extern size_t
+js_strlen(const jschar *s);
+
+extern int32_t
+js_strcmp(const jschar *lhs, const jschar *rhs);
+
+template <typename CharT>
+extern const CharT *
+js_strchr_limit(const CharT *s, jschar c, const CharT *limit);
+
+static MOZ_ALWAYS_INLINE void
+js_strncpy(jschar *dst, const jschar *src, size_t nelem)
+{
+    return mozilla::PodCopy(dst, src, nelem);
+}
+
+extern jschar *
+js_strdup(js::ThreadSafeContext *cx, const jschar *s);
+
 namespace js {
 
 /* GC-allocate a string descriptor for the given malloc-allocated chars. */
 template <js::AllowGC allowGC, typename CharT>
 extern JSFlatString *
 NewString(js::ThreadSafeContext *cx, CharT *chars, size_t length);
 
 extern JSLinearString *
 NewDependentString(JSContext *cx, JSString *base, size_t start, size_t length);
 
 /* Copy a counted string and GC-allocate a descriptor for it. */
 template <js::AllowGC allowGC, typename CharT>
 extern JSFlatString *
 NewStringCopyN(js::ThreadSafeContext *cx, const CharT *s, size_t n);
 
+template <js::AllowGC allowGC>
+inline JSFlatString *
+NewStringCopyN(ThreadSafeContext *cx, const char *s, size_t n)
+{
+    return NewStringCopyN<allowGC>(cx, reinterpret_cast<const Latin1Char *>(s), n);
+}
+
 /* Like NewStringCopyN, but doesn't try to deflate to Latin1. */
 template <js::AllowGC allowGC, typename CharT>
 extern JSFlatString *
 NewStringCopyNDontDeflate(js::ThreadSafeContext *cx, const CharT *s, size_t n);
 
 /* Copy a C string and GC-allocate a descriptor for it. */
 template <js::AllowGC allowGC>
-extern JSFlatString *
-NewStringCopyZ(js::ExclusiveContext *cx, const jschar *s);
+inline JSFlatString *
+NewStringCopyZ(js::ExclusiveContext *cx, const jschar *s)
+{
+    return NewStringCopyN<allowGC>(cx, s, js_strlen(s));
+}
 
 template <js::AllowGC allowGC>
-extern JSFlatString *
-NewStringCopyZ(js::ThreadSafeContext *cx, const char *s);
+inline JSFlatString *
+NewStringCopyZ(js::ThreadSafeContext *cx, const char *s)
+{
+    return NewStringCopyN<allowGC>(cx, s, strlen(s));
+}
 
 /*
  * Convert a non-string value to a string, returning null after reporting an
  * error, otherwise returning a new string reference.
  */
 template <AllowGC allowGC>
 extern JSString *
 ToStringSlow(ExclusiveContext *cx, typename MaybeRooted<Value, allowGC>::HandleType arg);
@@ -218,39 +250,16 @@ extern bool
 StringHasPattern(JSLinearString *text, const jschar *pat, uint32_t patlen);
 
 extern int
 StringFindPattern(JSLinearString *text, JSLinearString *pat, size_t start);
 
 extern bool
 StringHasRegExpMetaChars(JSLinearString *str);
 
-} /* namespace js */
-
-extern size_t
-js_strlen(const jschar *s);
-
-extern int32_t
-js_strcmp(const jschar *lhs, const jschar *rhs);
-
-template <typename CharT>
-extern const CharT *
-js_strchr_limit(const CharT *s, jschar c, const CharT *limit);
-
-static MOZ_ALWAYS_INLINE void
-js_strncpy(jschar *dst, const jschar *src, size_t nelem)
-{
-    return mozilla::PodCopy(dst, src, nelem);
-}
-
-extern jschar *
-js_strdup(js::ThreadSafeContext *cx, const jschar *s);
-
-namespace js {
-
 template <typename Char1, typename Char2>
 inline bool
 EqualChars(const Char1 *s1, const Char2 *s2, size_t len);
 
 template <typename Char1>
 inline bool
 EqualChars(const Char1 *s1, const Char1 *s2, size_t len)
 {