Bug 856304 - Replace some obsolete constructs. r=Neil
authoraceman <acelists@atlas.sk>
Sat, 13 Apr 2013 08:10:47 -0400
changeset 15365 a3df3ce94ea83218dc78d7f7b3b8a5ebdcf80800
parent 15364 8e1af095f1bb8e9236c1c0de897fa0aa0cc09004
child 15366 505edc73c23a1ec5c17baf653319402c1a1a4a90
push id920
push userbugzilla@standard8.plus.com
push dateMon, 24 Jun 2013 19:03:14 +0000
treeherdercomm-beta@936bfe9d120b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs856304
Bug 856304 - Replace some obsolete constructs. r=Neil
mailnews/addrbook/public/nsIAbLDIFService.idl
mailnews/addrbook/src/nsAbLDAPCard.cpp
mailnews/base/src/nsMsgAccountManager.cpp
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/util/nsImapMoveCoalescer.cpp
mailnews/base/util/nsMsgUtils.cpp
mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp
mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp
mailnews/local/src/nsParseMailbox.cpp
mailnews/news/src/nsNNTPNewsgroupList.cpp
mailnews/news/src/nsNntpIncomingServer.cpp
--- a/mailnews/addrbook/public/nsIAbLDIFService.idl
+++ b/mailnews/addrbook/public/nsIAbLDIFService.idl
@@ -10,19 +10,19 @@ interface nsIAddrDatabase;
 [scriptable, uuid(7afaa95f-0b1c-4d8a-a65f-bb5073ed6d39)]    
 interface nsIAbLDIFService : nsISupports {
 
   /**
    * Determine if a file is likely to be an LDIF file based on field
    * names that commonly appear in LDIF files.
    *
    * @param       aSrc   The file to examine
-   *    
-   * @return      PR_TRUE if the file appears to be of LDIF type,
-   *              PR_FALSE otherwise
+   *
+   * @return      true if the file appears to be of LDIF type,
+   *              false otherwise
    */
   boolean isLDIFFile(in nsIFile aSrc);
 
   /**
    * Imports a file into the specified address book.
    *
    * @param       aDb             The address book to import addresses into.
    *
--- a/mailnews/addrbook/src/nsAbLDAPCard.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPCard.cpp
@@ -69,17 +69,17 @@ NS_IMETHODIMP nsAbLDAPCard::GetLDAPMessa
   // classes: if an entry has additional object classes, it's probably
   // for a good reason.
   nsAutoCString oclass;
   for (uint32_t i = 0; i < aClassCount; ++i)
   {
     oclass.Assign(nsDependentCString(aClasses[i]));
     ToLowerCase(oclass);
    
-    if (m_objectClass.IndexOf(oclass) == nsTArray<nsCString>::NoIndex)
+    if (!m_objectClass.Contains(oclass))
     {
       m_objectClass.AppendElement(oclass);
       printf("LDAP : adding objectClass %s\n", oclass.get());
     }
   }
 
   nsCOMPtr<nsILDAPModification> mod =
     do_CreateInstance("@mozilla.org/network/ldap-modification;1", &rv);
@@ -160,22 +160,22 @@ NS_IMETHODIMP nsAbLDAPCard::GetLDAPMessa
       NS_ENSURE_SUCCESS(rv, rv);
  
       rv = mod->SetUpModificationOneValue(aType, attr, value);
       NS_ENSURE_SUCCESS(rv, rv);
     
       printf("LDAP : setting attribute %s (%s) to '%s'\n", attr.get(),
         props[i], propvalue.get());
       modArray->AppendElement(mod, false);
-      if (index != nsTArray<nsCString>::NoIndex)
+      if (index != m_attributes.NoIndex)
         m_attributes.AppendElement(attr);
 
     }
     else if (aType == nsILDAPModification::MOD_REPLACE &&
-             index != nsTArray<nsCString>::NoIndex)
+             index != m_attributes.NoIndex)
     {
       // If the new value is empty, we are performing an update
       // and the attribute was previously set, clear it
       nsCOMPtr<nsIMutableArray> novalues =
         do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
 
       rv = mod->SetUpModification(aType, attr, novalues);
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -3398,17 +3398,17 @@ NS_IMETHODIMP nsMsgAccountManager::OnIte
           {
             searchURI.Insert('|', 0);
             searchURI.Append('|');
           }
           nsCString folderURI;
           folder->GetURI(folderURI);
 
           int32_t index = searchURI.Find(folderURI);
-          if (index == -1)
+          if (index == kNotFound)
           {
             searchURI.Cut(0, 1);
             searchURI.Append(folderURI);
             dbFolderInfo->SetCharProperty(kSearchFolderUriProp, searchURI);
             break;
           }
           // New sent or archive folder, need to add sub-folders to smart folder.
           if (vfFolderFlag & (nsMsgFolderFlags::Archive | nsMsgFolderFlags::SentMail))
@@ -3500,17 +3500,17 @@ NS_IMETHODIMP nsMsgAccountManager::OnIte
     if (dbFolderInfo)
     {
       nsCString searchURI;
       dbFolderInfo->GetCharProperty(kSearchFolderUriProp, searchURI);
       // "normalize" searchURI so we can search for |folderURI|.
       searchURI.Insert('|', 0);
       searchURI.Append('|');
       int32_t index = searchURI.Find(removedFolderURI);
-      if (index != -1)
+      if (index != kNotFound)
       {
         RemoveVFListenerForVF(savedSearch, folder);
 
         // remove |folderURI
         searchURI.Cut(index, removedFolderURI.Length() - 1);
         // remove last '|' we added
         searchURI.SetLength(searchURI.Length() - 1);
 
@@ -3622,17 +3622,17 @@ nsMsgAccountManager::RemoveFolderFromSma
       if (vfFolderFlag & flagsChanged)
       {
         nsCString searchURI;
         dbFolderInfo->GetCharProperty(kSearchFolderUriProp, searchURI);
         // "normalize" searchURI so we can search for |folderURI|.
         searchURI.Insert('|', 0);
         searchURI.Append('|');
         int32_t index = searchURI.Find(removedFolderURI);
-        if (index != -1)
+        if (index != kNotFound)
         {
           RemoveVFListenerForVF(listener->m_virtualFolder, aFolder);
 
           // remove |folderURI
           searchURI.Cut(index, removedFolderURI.Length() - 1);
           // remove last '|' we added
           searchURI.SetLength(searchURI.Length() - 1);
 
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -1819,22 +1819,22 @@ bool nsMsgDBView::WasHdrRecentlyDeleted(
   msgHdr->GetMessageId(getter_Copies(messageId));
   return mRecentlyDeletedMsgIds.Contains(messageId);
 }
 
 //add a custom column handler
 NS_IMETHODIMP nsMsgDBView::AddColumnHandler(const nsAString& column, nsIMsgCustomColumnHandler* handler)
 {
 
-  int32_t index = m_customColumnHandlerIDs.IndexOf(column);
+  uint32_t index = m_customColumnHandlerIDs.IndexOf(column);
 
   nsAutoString strColID(column);
 
   //does not exist
-  if (index == -1)
+  if (index == m_customColumnHandlerIDs.NoIndex)
   {
     m_customColumnHandlerIDs.AppendElement(strColID);
     m_customColumnHandlers.AppendObject(handler);
   }
   else
   {
     //insert new handler into the appropriate place in the COMPtr array
     //no need to replace the column ID (it's the same)
@@ -3453,22 +3453,22 @@ nsMsgDBView::PerformActionsOnJunkMsgs(bo
             uint32_t flags;
             msgHdr->GetFlags(&flags);
             if (!(flags & nsMsgMessageFlags::IMAPDeleted))
               hdrsToDelete->AppendElement(msgHdr, false);
           }
         }
         hdrsToDelete->GetLength(&cnt);
         if (cnt)
-          rv = srcFolder->DeleteMessages(hdrsToDelete, msgWindow, PR_FALSE, PR_FALSE,
-                                         nullptr, PR_TRUE);
+          rv = srcFolder->DeleteMessages(hdrsToDelete, msgWindow, false, false,
+                                         nullptr, true);
       }
       else
-        rv = srcFolder->DeleteMessages(mJunkHdrs, msgWindow, PR_FALSE, PR_FALSE,
-                                       nullptr, PR_TRUE);
+        rv = srcFolder->DeleteMessages(mJunkHdrs, msgWindow, false, false,
+                                       nullptr, true);
 
     }
     else if (mDeleteModel == nsMsgImapDeleteModels::IMAPDelete)
     {
       nsCOMPtr<nsIMsgImapMailFolder> imapFolder(do_QueryInterface(srcFolder));
       nsTArray<nsMsgKey> imapUids;
       imapUids.SetLength(numJunkHdrs);
       for (uint32_t i = 0; i < numJunkHdrs; i++)
--- a/mailnews/base/util/nsImapMoveCoalescer.cpp
+++ b/mailnews/base/util/nsImapMoveCoalescer.cpp
@@ -43,17 +43,17 @@ nsresult nsImapMoveCoalescer::AddMove(ns
   else
   {
     m_destFolders.AppendObject(folder);
     keysToAdd = m_sourceKeyArrays.AppendElement();
     if (!keysToAdd)
       return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  if (keysToAdd->IndexOf(key) == nsTArray<nsMsgKey>::NoIndex)
+  if (!keysToAdd->Contains(key))
     keysToAdd->AppendElement(key);
 
   return NS_OK;
 }
 
 nsresult nsImapMoveCoalescer::PlaybackMoves(bool doNewMailNotification /* = false */)
 {
   int32_t numFolders = m_destFolders.Count();
--- a/mailnews/base/util/nsMsgUtils.cpp
+++ b/mailnews/base/util/nsMsgUtils.cpp
@@ -518,17 +518,17 @@ nsresult FormatFileSize(uint64_t size, b
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get rid of insignificant bits by truncating to 1 or 0 decimal points
   // 0.1 -> 0.1; 1.2 -> 1.2; 12.3 -> 12.3; 123.4 -> 123; 234.5 -> 235
   nsTextFormatter::ssprintf(
     formattedSize, sizeAbbr.get(),
     (unitIndex != 0) && (unitSize < 99.95 && unitSize != 0) ? 1 : 0, unitSize);
 
-  PRInt32 separatorPos = formattedSize.FindChar('.');
+  int32_t separatorPos = formattedSize.FindChar('.');
   if (separatorPos != kNotFound) {
     // The ssprintf returned a decimal number using a dot (.) as the decimal
     // separator. Now we try to localize the separator.
     // Try to get the decimal separator from the system's locale.
     char *decimalPoint;
 #ifdef HAVE_LOCALECONV
     struct lconv *locale = localeconv();
     decimalPoint = locale->decimal_point;
--- a/mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp
+++ b/mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp
@@ -2713,28 +2713,26 @@ void CorpusStore::remove(const char* wor
          word, aTraitId, aCount));
   CorpusToken* token = get(word);
   if (token)
     updateTrait(token, aTraitId, -static_cast<int32_t>(aCount));
 }
 
 uint32_t CorpusStore::getMessageCount(uint32_t aTraitId)
 {
-  const uint32_t kNoIndex = uint32_t(-1);
   uint32_t index = mMessageCountsId.IndexOf(aTraitId);
-  if (index == kNoIndex)
+  if (index == mMessageCountsId.NoIndex)
     return 0;
   return mMessageCounts.ElementAt(index);
 }
 
 void CorpusStore::setMessageCount(uint32_t aTraitId, uint32_t aCount)
 {
-  const uint32_t kNoIndex = uint32_t(-1);
   uint32_t index = mMessageCountsId.IndexOf(aTraitId);
-  if (index == kNoIndex)
+  if (index == mMessageCountsId.NoIndex)
   {
     mMessageCounts.AppendElement(aCount);
     mMessageCountsId.AppendElement(aTraitId);
   }
   else
   {
     mMessageCounts[index] = aCount;
   }
--- a/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp
+++ b/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp
@@ -253,17 +253,17 @@ nsresult nsMsgMailViewList::LoadMailView
     // this is kind of a hack but I think it will be an effective hack. The filter service already knows how to 
     // take a nsIFile and parse the contents into filters which are very similar to mail views. Intead of
     // re-writing all of that dirty parsing code, let's just re-use it then convert the results into a data strcuture
     // we wish to give to our consumers. 
       
     nsCOMPtr<nsIMsgFilterService> filterService = do_GetService(NS_MSGFILTERSERVICE_CONTRACTID, &rv);
     nsCOMPtr<nsIMsgFilterList> mfilterList;
       
-    rv = filterService->OpenFilterList(file, NULL, NULL, getter_AddRefs(mFilterList));
+    rv = filterService->OpenFilterList(file, nullptr, nullptr, getter_AddRefs(mFilterList));
     NS_ENSURE_SUCCESS(rv, rv);
 
     return ConvertFilterListToMailViews();
 }
 /**
  * Converts the filter list into our mail view objects,
  * stripping out just the info we need.
  */
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -1048,17 +1048,17 @@ nsresult nsParseMailMessageState::ParseH
 #ifdef MOZILLA_INTERNAL_API
       nsDependentCSubstring headerStr(buf, end);
 #else
       nsDependentCSubstring headerStr(buf, end - buf);
 #endif
 
       ToLowerCase(headerStr);
       uint32_t customHeaderIndex = m_customDBHeaders.IndexOf(headerStr);
-      if (customHeaderIndex != nsTArray<nsCString>::NoIndex)
+      if (customHeaderIndex != m_customDBHeaders.NoIndex)
         header = & m_customDBHeaderValues[customHeaderIndex];
     }
 
     buf = colon + 1;
     uint32_t writeOffset = 0; // number of characters replaced with a folded space
 
 SEARCH_NEWLINE:
     // move past any non terminating characters, rewriting them if folding white space
@@ -1147,18 +1147,17 @@ SEARCH_NEWLINE:
               m_receivedTime = resultTime;
             else
               NS_WARNING("PR_ParseTimeString failed in ParseHeaders().");
           }
         }
         // Someone might want the received header saved.
         if (m_customDBHeaders.Length())
         {
-          uint32_t customHeaderIndex = m_customDBHeaders.IndexOf(NS_LITERAL_CSTRING("received"));
-          if (customHeaderIndex != nsTArray<nsCString>::NoIndex)
+          if (m_customDBHeaders.Contains(NS_LITERAL_CSTRING("received")))
           {
             if (!m_receivedValue.IsEmpty())
               m_receivedValue.Append(' ');
             m_receivedValue.Append(header->value, header->length);
           }
         }
       }
     }
@@ -2590,17 +2589,17 @@ nsresult nsParseNewMailState::MoveIncorp
     notifier->NotifyMsgAdded(newHdr);
   // mark the header as not yet reported classified
   destIFolder->OrProcessingFlags(
     msgKey, nsMsgProcessingFlags::NotReportedClassified);
   m_msgToForwardOrReply = newHdr;
 
   if (movedMsgIsNew)
     destIFolder->SetHasNewMessages(true);
-  if (m_filterTargetFolders.IndexOf(destIFolder) == -1) // IndexOf() type?
+  if (!m_filterTargetFolders.Contains(destIFolder))
     m_filterTargetFolders.AppendObject(destIFolder);
 
   destIFolder->ReleaseSemaphore (myISupports);
 
   (void) localFolder->RefreshSizeOnDisk();
   destIFolder->SetFlag(nsMsgFolderFlags::GotNew);
 
   nsCOMPtr<nsIMsgPluggableStore> store;
--- a/mailnews/news/src/nsNNTPNewsgroupList.cpp
+++ b/mailnews/news/src/nsNNTPNewsgroupList.cpp
@@ -120,17 +120,17 @@ nsNNTPNewsgroupList::Initialize(nsINntpU
   m_serverFilterList->GetArbitraryHeaders(servHeaders);
 
   nsTArray<nsCString> servArray;
   ParseString(servHeaders, ' ', servArray);
 
   // servArray may have duplicates already in m_filterHeaders.
   for (uint32_t i = 0; i < servArray.Length(); i++)
   {
-    if (m_filterHeaders.IndexOf(servArray[i]) == m_filterHeaders.NoIndex)
+    if (!m_filterHeaders.Contains(servArray[i]))
       m_filterHeaders.AppendElement(servArray[i]);
   }
   return NS_OK;
 }
 
 nsresult
 nsNNTPNewsgroupList::CleanUp()
 {
@@ -1081,17 +1081,17 @@ nsNNTPNewsgroupList::AddHeader(const cha
   else if (PL_strcmp(header, "bytes") == 0)
   {
     rv = m_newMsgHdr->SetMessageSize(atol(value));
   }
   else if (PL_strcmp(header, "lines") == 0)
   {
     rv = m_newMsgHdr->SetLineCount(atol(value));
   }
-  else if (m_filterHeaders.IndexOf(nsDependentCString(header)) != m_filterHeaders.NoIndex)
+  else if (m_filterHeaders.Contains(nsDependentCString(header)))
   {
     rv = m_newMsgHdr->SetStringProperty(header, value);
   }
   return rv;
 }
 
 nsresult
 nsNNTPNewsgroupList::CallFilters()
--- a/mailnews/news/src/nsNntpIncomingServer.cpp
+++ b/mailnews/news/src/nsNntpIncomingServer.cpp
@@ -1068,17 +1068,17 @@ nsNntpIncomingServer::SetDelimiter(char 
     NS_ENSURE_SUCCESS(rv,rv);
     return mInner->SetDelimiter(aDelimiter);
 }
 
 NS_IMETHODIMP
 nsNntpIncomingServer::SetAsSubscribed(const nsACString &path)
 {
     mTempSubscribed.AppendElement(path);
-    if (mGetOnlyNew && (mGroupsOnServer.IndexOf(path) == mGroupsOnServer.NoIndex))
+    if (mGetOnlyNew && (!mGroupsOnServer.Contains(path)))
       return NS_OK;
 
     nsresult rv = EnsureInner();
     NS_ENSURE_SUCCESS(rv,rv);
     return mInner->SetAsSubscribed(path);
 }
 
 NS_IMETHODIMP
@@ -1725,17 +1725,17 @@ nsNntpIncomingServer::GetCellProperties(
     const PRUnichar* colID;
     col->GetIdConst(&colID);
     if (colID[0] == 's') {
         // if <name> is in our temporary list of subscribed groups
         // add the "subscribed" property so the check mark shows up
         // in the "subscribedCol"
         if (mSearchResultSortDescending)
           row = mSubscribeSearchResult.Length() - 1 - row;
-        if (mTempSubscribed.IndexOf(mSubscribeSearchResult.ElementAt(row)) != mTempSubscribed.NoIndex) {
+        if (mTempSubscribed.Contains(mSubscribeSearchResult.ElementAt(row))) {
           properties.AssignLiteral("subscribed");
         }
     }
     else if (colID[0] == 'n') {
       // add the "nntp" property to the "nameCol"
       // so we get the news folder icon in the search view
       properties.AssignLiteral("nntp");
     }