Bug 1455071 - Remove unused JSAutoStructuredCloneBuffer::copy, r=jorendorff
authorSteve Fink <sfink@mozilla.com>
Thu, 15 Mar 2018 20:09:09 -0700
changeset 467975 544004ece6c4a03dac37226d5b87b4c6c705c48a
parent 467974 c544503c6ae6a90444f37abe2716b1a30f68b545
child 467976 482a42df57acf26d446289eb9dc9c73c7f6de06f
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1455071
milestone61.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 1455071 - Remove unused JSAutoStructuredCloneBuffer::copy, r=jorendorff
js/public/StructuredClone.h
js/src/vm/StructuredClone.cpp
--- a/js/public/StructuredClone.h
+++ b/js/public/StructuredClone.h
@@ -458,21 +458,16 @@ class JS_PUBLIC_API(JSAutoStructuredClon
 
     ~JSAutoStructuredCloneBuffer() { clear(); }
 
     JSStructuredCloneData& data() { return data_; }
     bool empty() const { return !data_.Size(); }
 
     void clear();
 
-    /** Copy some memory. It will be automatically freed by the destructor. */
-    bool copy(JSContext* cx, const JSStructuredCloneData& data,
-              uint32_t version=JS_STRUCTURED_CLONE_VERSION,
-              const JSStructuredCloneCallbacks* callbacks=nullptr, void* closure=nullptr);
-
     /**
      * Adopt some memory. It will be automatically freed by the destructor.
      * data must have been allocated by the JS engine (e.g., extracted via
      * JSAutoStructuredCloneBuffer::steal).
      */
     void adopt(JSStructuredCloneData&& data, uint32_t version=JS_STRUCTURED_CLONE_VERSION,
                const JSStructuredCloneCallbacks* callbacks=nullptr, void* closure=nullptr);
 
--- a/js/src/vm/StructuredClone.cpp
+++ b/js/src/vm/StructuredClone.cpp
@@ -2828,43 +2828,16 @@ JSAutoStructuredCloneBuffer::clear()
     if (data_.ownTransferables_ == OwnTransferablePolicy::OwnsTransferablesIfAny)
         DiscardTransferables(data_, callbacks, closure);
     data_.ownTransferables_ = OwnTransferablePolicy::NoTransferables;
     data_.refsHeld_.releaseAll();
     data_.Clear();
     version_ = 0;
 }
 
-bool
-JSAutoStructuredCloneBuffer::copy(JSContext* cx, const JSStructuredCloneData& srcData,
-                                  uint32_t version, const JSStructuredCloneCallbacks* callbacks,
-                                  void* closure)
-{
-    // transferable objects cannot be copied
-    if (StructuredCloneHasTransferObjects(srcData))
-        return false;
-
-    clear();
-
-    auto iter = srcData.Iter();
-    while (!iter.Done()) {
-        if (!data_.WriteBytes(iter.Data(), iter.RemainingInSegment()))
-            return false;
-        iter.Advance(srcData, iter.RemainingInSegment());
-    }
-
-    version_ = version;
-
-    if (!data_.refsHeld_.acquireAll(cx, srcData.refsHeld_))
-        return false;
-
-    data_.setCallbacks(callbacks, closure, OwnTransferablePolicy::NoTransferables);
-    return true;
-}
-
 void
 JSAutoStructuredCloneBuffer::adopt(JSStructuredCloneData&& data, uint32_t version,
                                    const JSStructuredCloneCallbacks* callbacks,
                                    void* closure)
 {
     clear();
     data_ = Move(data);
     version_ = version;