Bug 969864 - Make nsTArray::SetLength return void; r=froydnj
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 19 Feb 2014 08:27:15 -0500
changeset 169491 dc5c250c91fc0bf8e746fcea557fd38b5b14068a
parent 169490 24ced312b229428ad4b47e1cdbba886adae092ef
child 169492 7ddfc587eddabbe32922d814cb65041ef5e88ffb
push id39964
push usereakhgari@mozilla.com
push dateWed, 19 Feb 2014 13:27:24 +0000
treeherdermozilla-inbound@dc5c250c91fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs969864
milestone30.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 969864 - Make nsTArray::SetLength return void; r=froydnj
xpcom/glue/nsCOMArray.cpp
xpcom/glue/nsTArray.h
--- a/xpcom/glue/nsCOMArray.cpp
+++ b/xpcom/glue/nsCOMArray.cpp
@@ -257,17 +257,18 @@ nsCOMArray_base::SetCount(int32_t aNewCo
 {
     NS_ASSERTION(aNewCount >= 0,"SetCount(negative index)");
     if (aNewCount < 0)
         return false;
 
     int32_t count = mArray.Length();
     if (count > aNewCount)
         RemoveObjectsAt(aNewCount, mArray.Length() - aNewCount);
-    return mArray.SetLength(aNewCount);
+    mArray.SetLength(aNewCount);
+    return true;
 }
 
 size_t
 nsCOMArray_base::SizeOfExcludingThis(
                    nsBaseArraySizeOfElementIncludingThisFunc aSizeOfElementIncludingThis,
                    mozilla::MallocSizeOf aMallocSizeOf, void* aData) const
 {
     size_t n = mArray.SizeOfExcludingThis(aMallocSizeOf);
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -1383,24 +1383,24 @@ public:
   // This method modifies the length of the array.  If the new length is
   // larger than the existing length of the array, then new elements will be
   // constructed using elem_type's default constructor.  Otherwise, this call
   // removes elements from the array (see also RemoveElementsAt).
   // @param newLen  The desired length of this array.
   // @return        True if the operation succeeded; false otherwise.
   // See also TruncateLength if the new length is guaranteed to be
   // smaller than the old.
-  bool SetLength(size_type newLen) {
+  typename Alloc::ResultType SetLength(size_type newLen) {
     size_type oldLen = Length();
     if (newLen > oldLen) {
-      return InsertElementsAt(oldLen, newLen - oldLen) != nullptr;
+      return Alloc::ConvertBoolToResultType(InsertElementsAt(oldLen, newLen - oldLen) != nullptr);
     }
 
     TruncateLength(newLen);
-    return true;
+    return Alloc::ConvertBoolToResultType(true);
   }
 
   // This method modifies the length of the array, but may only be
   // called when the new length is shorter than the old.  It can
   // therefore be called when elem_type has no default constructor,
   // unlike SetLength.  It removes elements from the array (see also
   // RemoveElementsAt).
   // @param newLen  The desired length of this array.