Bug 1494745 part 1 - Don't check the result from ns[Auto]TObserverArray::AppendElement since it's infallible. r=bz
authorMats Palmgren <mats@mozilla.com>
Sun, 14 Oct 2018 18:12:22 +0200
changeset 489485 4ac8ee3c801972a1c47e8270dccc801612c3aa21
parent 489484 d49587f5ccd37180d1f0d980c9dd076e7afa1bcb
child 489486 e0debd3f26f6d4ff98c8ede64aa05111864c56d0
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersbz
bugs1494745
milestone64.0a1
Bug 1494745 part 1 - Don't check the result from ns[Auto]TObserverArray::AppendElement since it's infallible. r=bz mChildList and mListenerInfoList are ns[Auto]TObserverArray which are infallible, so no need to check the return value from AppendElement (which a later patch in this series will remove).
uriloader/base/nsDocLoader.cpp
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -638,21 +638,18 @@ nsresult nsDocLoader::RemoveChildLoader(
   if (NS_SUCCEEDED(rv)) {
     rv = aChild->SetDocLoaderParent(nullptr);
   }
   return rv;
 }
 
 nsresult nsDocLoader::AddChildLoader(nsDocLoader* aChild)
 {
-  nsresult rv = mChildList.AppendElement(aChild) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
-  if (NS_SUCCEEDED(rv)) {
-    rv = aChild->SetDocLoaderParent(this);
-  }
-  return rv;
+  mChildList.AppendElement(aChild);
+  return aChild->SetDocLoaderParent(this);
 }
 
 NS_IMETHODIMP nsDocLoader::GetDocumentChannel(nsIChannel ** aChannel)
 {
   if (!mDocumentRequest) {
     *aChannel = nullptr;
     return NS_OK;
   }
@@ -878,18 +875,18 @@ nsDocLoader::AddProgressListener(nsIWebP
     return NS_ERROR_FAILURE;
   }
 
   nsWeakPtr listener = do_GetWeakReference(aListener);
   if (!listener) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  return mListenerInfoList.AppendElement(nsListenerInfo(listener, aNotifyMask)) ?
-         NS_OK : NS_ERROR_OUT_OF_MEMORY;
+  mListenerInfoList.AppendElement(nsListenerInfo(listener, aNotifyMask));
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocLoader::RemoveProgressListener(nsIWebProgressListener *aListener)
 {
   return mListenerInfoList.RemoveElement(aListener) ? NS_OK : NS_ERROR_FAILURE;
 }