Bug 1633144 - adjust array methods that are now infallible following bug 1628715. rs=bustage-fix
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Sat, 25 Apr 2020 15:37:59 +0300
changeset 38932 6301c1c36be285b447012da86123d0f5493ffe25
parent 38931 cb1266d16fcfdfc2a971656d32e2d3b7b7ab4741
child 38933 99b6256ea0bf453e35ca224c3c14b285a274ba52
push id401
push userclokep@gmail.com
push dateMon, 01 Jun 2020 20:41:59 +0000
reviewersbustage-fix
bugs1633144, 1628715
Bug 1633144 - adjust array methods that are now infallible following bug 1628715. rs=bustage-fix Build bustage 2020-04-25: nsAbView.cpp:298:25: error: no viable conversion from 'mozilla::NotNull<elem_type *>' (aka 'NotNull<AbCard **>') to 'DebugOnly<bool>'
mailnews/addrbook/src/nsAbView.cpp
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/src/nsMsgDBView.h
mailnews/base/src/nsMsgSearchDBView.cpp
mailnews/base/src/nsMsgSearchDBView.h
mailnews/base/src/nsMsgTagService.cpp
--- a/mailnews/addrbook/src/nsAbView.cpp
+++ b/mailnews/addrbook/src/nsAbView.cpp
@@ -290,18 +290,17 @@ nsresult nsAbView::EnumerateCards() {
         AbCard *abcard = new AbCard(card);
 
         // XXX todo
         // Would it be better to do an insertion sort, than append and sort?
         // XXX todo
         // If we knew how many cards there was going to be
         // we could allocate an array of the size,
         // instead of growing and copying as we append.
-        DebugOnly<bool> didAppend = mCards.AppendElement(abcard);
-        NS_ASSERTION(didAppend, "failed to append card");
+        mCards.AppendElement(abcard);
       }
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsAbView::GetRowCount(int32_t *aRowCount) {
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -5329,20 +5329,20 @@ nsresult nsMsgDBView::ListIdsInThreadOrd
     }
   }
 
   // We don't want to return the rv from the enumerator when it reaches the
   // end, do we?
   return rv;
 }
 
-bool nsMsgDBView::InsertEmptyRows(nsMsgViewIndex viewIndex, int32_t numRows) {
-  return m_keys.InsertElementsAt(viewIndex, numRows, 0) &&
-         m_flags.InsertElementsAt(viewIndex, numRows, 0) &&
-         m_levels.InsertElementsAt(viewIndex, numRows, 1);
+void nsMsgDBView::InsertEmptyRows(nsMsgViewIndex viewIndex, int32_t numRows) {
+  m_keys.InsertElementsAt(viewIndex, numRows, 0);
+  m_flags.InsertElementsAt(viewIndex, numRows, 0);
+  m_levels.InsertElementsAt(viewIndex, numRows, 1);
 }
 
 void nsMsgDBView::RemoveRows(nsMsgViewIndex viewIndex, int32_t numRows) {
   m_keys.RemoveElementsAt(viewIndex, numRows);
   m_flags.RemoveElementsAt(viewIndex, numRows);
   m_levels.RemoveElementsAt(viewIndex, numRows);
 }
 
@@ -5357,22 +5357,20 @@ nsMsgDBView::InsertTreeRows(nsMsgViewInd
     // In a search/xfvf view only, a folder is required.
     NS_ENSURE_ARG_POINTER(aFolder);
     for (size_t i = 0; i < aNumRows; i++)
       // Insert into m_folders.
       if (!folders->InsertObjectAt(aFolder, aIndex + i))
         return NS_ERROR_UNEXPECTED;
   }
 
-  if (m_keys.InsertElementsAt(aIndex, aNumRows, aKey) &&
-      m_flags.InsertElementsAt(aIndex, aNumRows, aFlags) &&
-      m_levels.InsertElementsAt(aIndex, aNumRows, aLevel))
-    return NS_OK;
-
-  return NS_ERROR_UNEXPECTED;
+  m_keys.InsertElementsAt(aIndex, aNumRows, aKey);
+  m_flags.InsertElementsAt(aIndex, aNumRows, aFlags);
+  m_levels.InsertElementsAt(aIndex, aNumRows, aLevel);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgDBView::RemoveTreeRows(nsMsgViewIndex aIndex, uint32_t aNumRows) {
   // Prevent a crash if attempting to remove rows which don't exist.
   if (GetSize() < aIndex + aNumRows) return NS_ERROR_UNEXPECTED;
 
   nsMsgDBView::RemoveRows(aIndex, aNumRows);
@@ -5397,17 +5395,17 @@ nsresult nsMsgDBView::ListIdsInThread(ns
 
   uint32_t numChildren;
   threadHdr->GetNumChildren(&numChildren);
   NS_ASSERTION(numChildren, "Empty thread in view/db");
   if (!numChildren) return NS_OK;
 
   // Account for the existing thread root.
   numChildren--;
-  if (!InsertEmptyRows(viewIndex, numChildren)) return NS_ERROR_OUT_OF_MEMORY;
+  InsertEmptyRows(viewIndex, numChildren);
 
   // ### need to rework this when we implemented threading in group views.
   if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay &&
       !(m_viewFlags & nsMsgViewFlagsType::kGroupBySort)) {
     nsMsgKey parentKey = m_keys[startOfThreadViewIndex];
     // If the thread is bigger than the hdr cache, expanding the thread
     // can be slow. Increasing the hdr cache size will help a fair amount.
     uint32_t hdrCacheSize;
--- a/mailnews/base/src/nsMsgDBView.h
+++ b/mailnews/base/src/nsMsgDBView.h
@@ -201,17 +201,17 @@ class nsMsgDBView : public nsIMsgDBView,
                                          nsIMsgDBHdr **msgHdr);
   // Given a view index, return the index of the top-level msg in the thread.
   nsMsgViewIndex GetThreadIndex(nsMsgViewIndex msgIndex);
 
   virtual void InsertMsgHdrAt(nsMsgViewIndex index, nsIMsgDBHdr *hdr,
                               nsMsgKey msgKey, uint32_t flags, uint32_t level);
   virtual void SetMsgHdrAt(nsIMsgDBHdr *hdr, nsMsgViewIndex index,
                            nsMsgKey msgKey, uint32_t flags, uint32_t level);
-  virtual bool InsertEmptyRows(nsMsgViewIndex viewIndex, int32_t numRows);
+  virtual void InsertEmptyRows(nsMsgViewIndex viewIndex, int32_t numRows);
   virtual void RemoveRows(nsMsgViewIndex viewIndex, int32_t numRows);
   nsresult ToggleExpansion(nsMsgViewIndex index, uint32_t *numChanged);
   nsresult ExpandByIndex(nsMsgViewIndex index, uint32_t *pNumExpanded);
   nsresult CollapseByIndex(nsMsgViewIndex index, uint32_t *pNumCollapsed);
   nsresult ExpandAll();
   nsresult CollapseAll();
   nsresult ExpandAndSelectThread();
 
--- a/mailnews/base/src/nsMsgSearchDBView.cpp
+++ b/mailnews/base/src/nsMsgSearchDBView.cpp
@@ -306,20 +306,20 @@ void nsMsgSearchDBView::SetMsgHdrAt(nsIM
   m_keys[index] = msgKey;
   m_flags[index] = flags;
   m_levels[index] = level;
   nsCOMPtr<nsIMsgFolder> folder;
   hdr->GetFolder(getter_AddRefs(folder));
   m_folders.ReplaceObjectAt(folder, index);
 }
 
-bool nsMsgSearchDBView::InsertEmptyRows(nsMsgViewIndex viewIndex,
+void nsMsgSearchDBView::InsertEmptyRows(nsMsgViewIndex viewIndex,
                                         int32_t numRows) {
   for (int32_t i = 0; i < numRows; i++) {
-    if (!m_folders.InsertObjectAt(nullptr, viewIndex + i)) return false;
+    m_folders.InsertObjectAt(nullptr, viewIndex + i);
   }
 
   return nsMsgDBView::InsertEmptyRows(viewIndex, numRows);
 }
 
 void nsMsgSearchDBView::RemoveRows(nsMsgViewIndex viewIndex, int32_t numRows) {
   nsMsgDBView::RemoveRows(viewIndex, numRows);
   for (int32_t i = 0; i < numRows; i++) m_folders.RemoveObjectAt(viewIndex);
@@ -1309,17 +1309,17 @@ nsresult nsMsgSearchDBView::ListIdsInThr
 
   uint32_t numChildren;
   threadHdr->GetNumChildren(&numChildren);
   NS_ASSERTION(numChildren, "Empty thread in view/db");
   if (!numChildren) return NS_OK;
 
   // Account for the existing thread root.
   numChildren--;
-  if (!InsertEmptyRows(viewIndex, numChildren)) return NS_ERROR_OUT_OF_MEMORY;
+  InsertEmptyRows(viewIndex, numChildren);
 
   bool threadedView = m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay &&
                       !(m_viewFlags & nsMsgViewFlagsType::kGroupBySort);
   nsMsgXFViewThread *viewThread;
   if (threadedView) viewThread = static_cast<nsMsgXFViewThread *>(threadHdr);
 
   for (i = 1; i <= numChildren; i++) {
     nsCOMPtr<nsIMsgDBHdr> msgHdr;
--- a/mailnews/base/src/nsMsgSearchDBView.h
+++ b/mailnews/base/src/nsMsgSearchDBView.h
@@ -103,17 +103,17 @@ class nsMsgSearchDBView : public nsMsgGr
                                   int32_t numIndices,
                                   bool deleteStorage) override;
   virtual void InsertMsgHdrAt(nsMsgViewIndex index, nsIMsgDBHdr *hdr,
                               nsMsgKey msgKey, uint32_t flags,
                               uint32_t level) override;
   virtual void SetMsgHdrAt(nsIMsgDBHdr *hdr, nsMsgViewIndex index,
                            nsMsgKey msgKey, uint32_t flags,
                            uint32_t level) override;
-  virtual bool InsertEmptyRows(nsMsgViewIndex viewIndex,
+  virtual void InsertEmptyRows(nsMsgViewIndex viewIndex,
                                int32_t numRows) override;
   virtual void RemoveRows(nsMsgViewIndex viewIndex, int32_t numRows) override;
   virtual nsMsgViewIndex FindHdr(nsIMsgDBHdr *msgHdr,
                                  nsMsgViewIndex startIndex = 0,
                                  bool allowDummy = false) override;
   nsresult GetFoldersAndHdrsForSelection(nsMsgViewIndex *indices,
                                          int32_t numIndices);
   nsresult GroupSearchResultsByFolder();
--- a/mailnews/base/src/nsMsgTagService.cpp
+++ b/mailnews/base/src/nsMsgTagService.cpp
@@ -459,15 +459,12 @@ nsresult nsMsgTagService::RefreshKeyCach
   NS_ENSURE_SUCCESS(rv, rv);
   m_keys.Clear();
 
   uint32_t numTags = tagArray.Length();
   m_keys.SetCapacity(numTags);
   for (uint32_t tagIndex = 0; tagIndex < numTags; tagIndex++) {
     nsAutoCString key;
     tagArray[tagIndex]->GetKey(key);
-    if (!m_keys.InsertElementAt(tagIndex, key)) {
-      rv = NS_ERROR_FAILURE;
-      break;
-    }
+    m_keys.InsertElementAt(tagIndex, key);
   }
   return rv;
 }