Bug 1551782. Remove now-unused nsCOMArray::Forget and nsCOMArray::Adopt methods. r=froydnj
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 16 May 2019 15:13:44 +0000
changeset 474107 cf3ffc5477de947590d7b9b4a1cd9dc77619cfb9
parent 474106 82903bdb446a0c780a3faaf503cea8a6dc43550c
child 474108 6f7ed4fc33113c365c1c97a9ad7c7a8a9c1bc54d
push id36022
push userncsoregi@mozilla.com
push dateThu, 16 May 2019 21:55:16 +0000
treeherdermozilla-central@96802be91766 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1551782
milestone68.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 1551782. Remove now-unused nsCOMArray::Forget and nsCOMArray::Adopt methods. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D31246
xpcom/ds/nsCOMArray.cpp
xpcom/ds/nsCOMArray.h
--- a/xpcom/ds/nsCOMArray.cpp
+++ b/xpcom/ds/nsCOMArray.cpp
@@ -245,29 +245,8 @@ bool nsCOMArray_base::SetCount(int32_t a
 
   int32_t count = mArray.Length();
   if (count > aNewCount) {
     RemoveObjectsAt(aNewCount, mArray.Length() - aNewCount);
   }
   mArray.SetLength(aNewCount);
   return true;
 }
-
-void nsCOMArray_base::Adopt(nsISupports** aElements, uint32_t aSize) {
-  Clear();
-  mArray.AppendElements(aElements, aSize);
-
-  // Free the allocated array as well.
-  free(aElements);
-}
-
-uint32_t nsCOMArray_base::Forget(nsISupports*** aElements) {
-  uint32_t length = Length();
-  size_t array_size = sizeof(nsISupports*) * length;
-  nsISupports** array = static_cast<nsISupports**>(moz_xmalloc(array_size));
-  memmove(array, Elements(), array_size);
-  *aElements = array;
-  // Don't Release the contained pointers; the caller of the method will
-  // do this eventually.
-  mArray.Clear();
-
-  return length;
-}
--- a/xpcom/ds/nsCOMArray.h
+++ b/xpcom/ds/nsCOMArray.h
@@ -89,19 +89,16 @@ class nsCOMArray_base {
     return InsertElementsAt(Length(), aElements, aCount);
   }
   bool RemoveObject(nsISupports* aObject);
   nsISupports** Elements() { return mArray.Elements(); }
   void SwapElements(nsCOMArray_base& aOther) {
     mArray.SwapElements(aOther.mArray);
   }
 
-  void Adopt(nsISupports** aElements, uint32_t aCount);
-  uint32_t Forget(nsISupports*** aElements);
-
  public:
   // elements in the array (including null elements!)
   int32_t Count() const { return mArray.Length(); }
   // nsTArray-compatible version
   uint32_t Length() const { return mArray.Length(); }
   bool IsEmpty() const { return mArray.IsEmpty(); }
 
   // If the array grows, the newly created entries will all be null;
@@ -340,43 +337,16 @@ class nsCOMArray : public nsCOMArray_bas
     return nsCOMArray_base::RemoveObject(aElement);
   }
 
   T** Elements() { return reinterpret_cast<T**>(nsCOMArray_base::Elements()); }
   void SwapElements(nsCOMArray<T>& aOther) {
     nsCOMArray_base::SwapElements(aOther);
   }
 
-  /**
-   * Adopt parameters that resulted from an XPIDL outparam. The aElements
-   * parameter will be freed as a result of the call.
-   *
-   * Example usage:
-   * nsCOMArray<nsISomeInterface> array;
-   * nsISomeInterface** elements;
-   * uint32_t length;
-   * ptr->GetSomeArray(&elements, &length);
-   * array.Adopt(elements, length);
-   */
-  void Adopt(T** aElements, uint32_t aSize) {
-    nsCOMArray_base::Adopt(reinterpret_cast<nsISupports**>(aElements), aSize);
-  }
-
-  /**
-   * Export the contents of this array to an XPIDL outparam. The array will be
-   * Clear()'d after this operation.
-   *
-   * Example usage:
-   * nsCOMArray<nsISomeInterface> array;
-   * *length = array.Forget(retval);
-   */
-  uint32_t Forget(T*** aElements) {
-    return nsCOMArray_base::Forget(reinterpret_cast<nsISupports***>(aElements));
-  }
-
   // Methods for range-based for loops.
   iterator begin() { return iterator(*this, 0); }
   const_iterator begin() const { return const_iterator(*this, 0); }
   const_iterator cbegin() const { return begin(); }
   iterator end() { return iterator(*this, Length()); }
   const_iterator end() const { return const_iterator(*this, Length()); }
   const_iterator cend() const { return end(); }