Bug 700498 - Change StringBuffer::append to take a JSLinearString*, not a JSAtom*. r=cdleary
authorJeff Walden <jwalden@mit.edu>
Mon, 07 Nov 2011 16:28:37 -0800
changeset 79959 7ee6348181394bcabe262a9aacb34c6ac5411fb7
parent 79958 69f7d8cc0c00f785984183df7b4ee4b30db09bd3
child 79960 6b2d55b83aa954172450ab4bab67499832a3b504
push id3223
push userjwalden@mit.edu
push dateTue, 08 Nov 2011 01:38:05 +0000
treeherdermozilla-inbound@be3714af7869 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscdleary
bugs700498
milestone10.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 700498 - Change StringBuffer::append to take a JSLinearString*, not a JSAtom*. r=cdleary
js/src/jsstrinlines.h
--- a/js/src/jsstrinlines.h
+++ b/js/src/jsstrinlines.h
@@ -72,17 +72,17 @@ class StringBuffer
   public:
     explicit inline StringBuffer(JSContext *cx);
     bool reserve(size_t len);
     bool resize(size_t len);
     bool append(const jschar c);
     bool append(const jschar *chars, size_t len);
     bool append(const jschar *begin, const jschar *end);
     bool append(JSString *str);
-    bool append(JSAtom *atom);
+    bool append(JSLinearString *str);
     bool appendN(const jschar c, size_t n);
     bool appendInflated(const char *cstr, size_t len);
 
     /* Infallible variants usable when the corresponding space is reserved. */
     void infallibleAppend(const jschar c) {
         cb.infallibleAppend(c);
     }
     void infallibleAppend(const jschar *chars, size_t len) {
@@ -168,29 +168,24 @@ StringBuffer::append(const jschar *begin
 }
 
 inline bool
 StringBuffer::append(JSString *str)
 {
     JSLinearString *linear = str->ensureLinear(context());
     if (!linear)
         return false;
-    size_t strLen = linear->length();
-    if (!checkLength(cb.length() + strLen))
-        return false;
-    return cb.append(linear->chars(), strLen);
+    return append(linear);
 }
 
 inline bool
-StringBuffer::append(JSAtom *atom)
+StringBuffer::append(JSLinearString *str)
 {
-    size_t strLen = atom->length();
-    if (!checkLength(cb.length() + strLen))
-        return false;
-    return cb.append(atom->chars(), strLen);
+    JS::Anchor<JSString *> anch(str);
+    return cb.append(str->chars(), str->length());
 }
 
 inline bool
 StringBuffer::appendN(const jschar c, size_t n)
 {
     if (!checkLength(cb.length() + n))
         return false;
     return cb.appendN(c, n);