Bug 476150 Move more ParseString users from nsCStringArray to nsTArray<nsCString> r=Standard8 sr=bienvenu
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Sat, 21 Feb 2009 21:58:38 +0000
changeset 2014 1f0be0d2b89f05f446be7707e0557cdd88c9f43b
parent 2013 f99c51271d929869f76045ab6ae28d79f997e8fc
child 2015 a97a2151b1f960bd5028fbf9ad4b285500aa5c3c
push id1631
push userneil@parkwaycc.co.uk
push dateSat, 21 Feb 2009 21:58:44 +0000
treeherdercomm-central@1f0be0d2b89f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, bienvenu
bugs476150
Bug 476150 Move more ParseString users from nsCStringArray to nsTArray<nsCString> r=Standard8 sr=bienvenu
mailnews/addrbook/src/nsAbLDAPDirectory.cpp
mailnews/base/search/src/nsMsgSearchTerm.cpp
mailnews/base/src/nsMsgAccountManager.cpp
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/src/nsMsgTagService.cpp
mailnews/base/util/nsMsgDBFolder.cpp
mailnews/base/util/nsMsgUtils.cpp
mailnews/base/util/nsMsgUtils.h
mailnews/compose/src/nsMsgSendLater.cpp
mailnews/imap/src/nsImapProtocol.cpp
mailnews/imap/src/nsImapProtocol.h
mailnews/local/src/nsLocalMailFolder.cpp
mailnews/local/src/nsParseMailbox.cpp
mailnews/local/src/nsParseMailbox.h
mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp
mailnews/mime/src/mimei.h
mailnews/mime/src/mimemult.cpp
mailnews/news/src/nsNNTPNewsgroupList.cpp
mailnews/news/src/nsNNTPNewsgroupList.h
mailnews/news/src/nsNntpService.cpp
--- a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp
@@ -937,30 +937,30 @@ NS_IMETHODIMP nsAbLDAPDirectory::SetObje
 nsresult nsAbLDAPDirectory::SplitStringList(
   const nsACString& aString,
   PRUint32 *aCount,
   char ***aValues)
 {
   NS_ENSURE_ARG_POINTER(aCount);
   NS_ENSURE_ARG_POINTER(aValues);
 
-  nsCStringArray strarr;
+  nsTArray<nsCString> strarr;
   ParseString(aString, ',', strarr);
 
   char **cArray = nsnull;
   if (!(cArray = static_cast<char **>(nsMemory::Alloc(
-      strarr.Count() * sizeof(char *)))))
+      strarr.Length() * sizeof(char *)))))
     return NS_ERROR_OUT_OF_MEMORY;
 
-  for (PRInt32 i = 0; i < strarr.Count(); ++i)
+  for (PRUint32 i = 0; i < strarr.Length(); ++i)
   {
-    if (!(cArray[i] = ToNewCString(*strarr.CStringAt(i))))
+    if (!(cArray[i] = ToNewCString(strarr[i])))
     {
-      NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(strarr.Count(), cArray);
+      NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(strarr.Length(), cArray);
       return NS_ERROR_OUT_OF_MEMORY;
     }
   }
 
-  *aCount = strarr.Count();
+  *aCount = strarr.Length();
   *aValues = cArray;
   return NS_OK;
 }
 
--- a/mailnews/base/search/src/nsMsgSearchTerm.cpp
+++ b/mailnews/base/search/src/nsMsgSearchTerm.cpp
@@ -1474,41 +1474,41 @@ nsresult nsMsgSearchTerm::MatchKeyword(c
     }
     // keyword not found
     *pResult = m_operator == nsMsgSearchOp::DoesntContain;
     return NS_OK;
   }
 
   // Only accept valid keys in tokens.
   nsresult rv = NS_OK;
-  nsCStringArray keywordArray;
+  nsTArray<nsCString> keywordArray;
   ParseString(keywordList, ' ', keywordArray);
   nsCOMPtr<nsIMsgTagService> tagService(do_GetService(NS_MSGTAGSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Loop through tokens in keywords
-  PRUint32 count = keywordArray.Count();
+  PRUint32 count = keywordArray.Length();
   for (PRUint32 i = 0; i < count; i++)
   {
     // is this token a valid tag? Otherwise ignore it
     PRBool isValid;
-    rv = tagService->IsValidKey(*keywordArray[i], &isValid);
+    rv = tagService->IsValidKey(keywordArray[i], &isValid);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (isValid)
     {
       // IsEmpty fails on any valid token
       if (m_operator == nsMsgSearchOp::IsEmpty)
       {
         *pResult = PR_FALSE;
         return rv;
       }
 
       // Does this valid tag key match our search term?
-      matches = keywordArray[i]->Equals(m_value.string);
+      matches = keywordArray[i].Equals(m_value.string);
 
       // Is or Isn't partly determined on a single unmatched token
       if (!matches)
       {
         if (m_operator == nsMsgSearchOp::Is)
         {
           *pResult = PR_FALSE;
           return rv;
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -2918,23 +2918,23 @@ nsresult nsMsgAccountManager::WriteLineT
   return NS_OK;
 }
 
 nsresult nsMsgAccountManager::AddVFListenersForVF(nsIMsgFolder *virtualFolder,
                                                   const nsCString& srchFolderUris,
                                                   nsIRDFService *rdf,
                                                   nsIMsgDBService *msgDBService)
 {
-  nsCStringArray folderUris;
+  nsTArray<nsCString> folderUris;
   ParseString(srchFolderUris, '|', folderUris);
   nsCOMPtr <nsIRDFResource> resource;
 
-  for (PRInt32 i = 0; i < folderUris.Count(); i++)
+  for (PRUint32 i = 0; i < folderUris.Length(); i++)
   {
-    rdf->GetResource(*(folderUris[i]), getter_AddRefs(resource));
+    rdf->GetResource(folderUris[i], getter_AddRefs(resource));
     nsCOMPtr <nsIMsgFolder> realFolder = do_QueryInterface(resource);
     VirtualFolderChangeListener *dbListener = new VirtualFolderChangeListener();
     NS_ENSURE_TRUE(dbListener, NS_ERROR_OUT_OF_MEMORY);
     m_virtualFolderListeners.AppendObject(dbListener);
     dbListener->m_virtualFolder = virtualFolder;
     dbListener->m_folderWatching = realFolder;
     dbListener->Init();
     msgDBService->RegisterPendingListener(realFolder, dbListener);
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -698,23 +698,23 @@ nsresult nsMsgDBView::FetchTags(nsIMsgDB
   if (label > 0)
   {
     nsCAutoString labelStr("$label");
     labelStr.Append((char) (label + '0'));
     if (keywords.Find(labelStr, PR_TRUE) == -1)
       FetchLabel(aHdr, tags);
   }
 
-  nsCStringArray keywordsArray;
+  nsTArray<nsCString> keywordsArray;
   ParseString(keywords, ' ', keywordsArray);
   nsAutoString tag;
 
-  for (PRInt32 i = 0; i < keywordsArray.Count(); i++)
-  {
-    rv = mTagService->GetTagForKey(*(keywordsArray[i]), tag);
+  for (PRUint32 i = 0; i < keywordsArray.Length(); i++)
+  {
+    rv = mTagService->GetTagForKey(keywordsArray[i], tag);
     if (NS_SUCCEEDED(rv) && !tag.IsEmpty())
     {
       if (!tags.IsEmpty())
         tags.Append((PRUnichar) ' ');
       tags.Append(tag);
     }
   }
 
--- a/mailnews/base/src/nsMsgTagService.cpp
+++ b/mailnews/base/src/nsMsgTagService.cpp
@@ -216,23 +216,23 @@ NS_IMETHODIMP nsMsgTagService::GetKeyFor
   return NS_OK;
 }
 
 /* ACString getTopKey (in ACString keylist); */
 NS_IMETHODIMP nsMsgTagService::GetTopKey(const nsACString & keyList, nsACString & _retval)
 {
   _retval.Truncate();
   // find the most important key
-  nsCStringArray keyArray;
+  nsTArray<nsCString> keyArray;
   ParseString(keyList, ' ', keyArray);
-  PRUint32 keyCount = keyArray.Count();
+  PRUint32 keyCount = keyArray.Length();
   nsCString *topKey = nsnull, *key, topOrdinal, ordinal;
   for (PRUint32 i = 0; i < keyCount; ++i)
   {
-    key = keyArray[i];
+    key = &keyArray[i];
     if (key->IsEmpty())
       continue;
 
     // ignore unknown keywords
     nsAutoString tagValue;
     nsresult rv = GetTagForKey(*key, tagValue);
     if (NS_FAILED(rv) || tagValue.IsEmpty())
       continue;
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -2080,23 +2080,23 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgW
   {
     spamSettings->GetWhiteListAbURI(getter_Copies(whiteListAbURI));
     NS_ENSURE_SUCCESS(rv, rv);
     if (!whiteListAbURI.IsEmpty())
     {
       nsCOMPtr <nsIRDFService> rdfService = do_GetService("@mozilla.org/rdf/rdf-service;1",&rv);
       NS_ENSURE_SUCCESS(rv, rv);
 
-      nsCStringArray whiteListArray;
+      nsTArray<nsCString> whiteListArray;
       ParseString(whiteListAbURI, ' ', whiteListArray);
 
-      for (PRInt32 index = 0; index < whiteListArray.Count(); index++)
+      for (PRUint32 index = 0; index < whiteListArray.Length(); index++)
       {
         nsCOMPtr<nsIRDFResource> resource;
-        rv = rdfService->GetResource(*whiteListArray[index], getter_AddRefs(resource));
+        rv = rdfService->GetResource(whiteListArray[index], getter_AddRefs(resource));
 
         nsCOMPtr<nsIAbDirectory> whiteListDirectory =
           do_QueryInterface(resource, &rv);
         if (whiteListDirectory)
           whiteListDirArray.AppendObject(whiteListDirectory);
       }
     }
     // if we can't get the db, we probably want to continue firing spam filters.
@@ -5269,27 +5269,27 @@ NS_IMETHODIMP nsMsgDBFolder::AddKeywords
     nsCString keywords;
 
     for(PRUint32 i = 0; i < count; i++)
     {
       nsCOMPtr<nsIMsgDBHdr> message = do_QueryElementAt(aMessages, i, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
 
       message->GetStringProperty("keywords", getter_Copies(keywords));
-      nsCStringArray keywordArray;
+      nsTArray<nsCString> keywordArray;
       ParseString(aKeywords, ' ', keywordArray);
       PRUint32 addCount = 0;
-      for (PRInt32 j = 0; j < keywordArray.Count(); j++)
+      for (PRUint32 j = 0; j < keywordArray.Length(); j++)
       {
         PRInt32 start, length;
-        if (!MsgFindKeyword(*(keywordArray[j]), keywords, &start, &length))
+        if (!MsgFindKeyword(keywordArray[j], keywords, &start, &length))
         {
           if (!keywords.IsEmpty())
             keywords.Append(' ');
-          keywords.Append(keywordArray[j]->get());
+          keywords.Append(keywordArray[j]);
           addCount++;
         }
       }
       // avoid using the message key to set the string property, because
       // in the case of filters running on incoming pop3 mail with quarantining
       // turned on, the message key is wrong.
       mDatabase->SetStringPropertyByHdr(message, "keywords", keywords.get());
       
--- a/mailnews/base/util/nsMsgUtils.cpp
+++ b/mailnews/base/util/nsMsgUtils.cpp
@@ -1875,37 +1875,16 @@ NS_MSG_BASE PRBool ParseString(const cha
           array.RemoveCStringAt(array.Count() - 1);
         return PR_FALSE;
       }
     }
   }
   return PR_TRUE;
 }
 
-NS_MSG_BASE PRBool ParseString(const nsACString& string, char delimiter, nsCStringArray& array)
-{
-  if (string.IsEmpty())
-    return PR_TRUE;
-
-  PRInt32 count = array.Count();
-  PRInt32 start = 0;
-  for (;;) {
-    PRInt32 end = string.FindChar(delimiter, start);
-    if (end != start && !array.AppendCString(Substring(string, start, end - start)))
-      break;
-    if (end == -1)
-      return PR_TRUE;
-    start = end + 1;
-  }
-
-  while (array.Count() > count)
-    array.RemoveCStringAt(array.Count() - 1);
-  return PR_FALSE;
-}
-
 #ifdef MOZILLA_1_9_1_BRANCH
 NS_MSG_BASE PRBool ParseString(const nsACString& string, char delimiter, nsTArray<nsCString>& array)
 {
   if (string.IsEmpty())
     return PR_TRUE;
 
   PRUint32 count = array.Length();
   PRInt32 start = 0;
--- a/mailnews/base/util/nsMsgUtils.h
+++ b/mailnews/base/util/nsMsgUtils.h
@@ -221,30 +221,16 @@ NS_MSG_BASE nsresult MsgGetHeadersFromKe
  * @param delims
  *        A set of delimter characters.
  * @param array
  *        The array to append tokens to.
  * @deprecated This call needs to be converted to the nsTArray<nsCString> api.
  */
 NS_MSG_BASE PRBool ParseString(const char *string, const char *delims, nsCStringArray& array);
 
-/**
- * Parses a given string using the delimiter passed in. Items parsed from the
- * string will be appended to the array.
- *
- * @param string
- *        The string to parse.
- * @param delimiter
- *        A delimter character.
- * @param array
- *        The array to append tokens to.
- * @deprecated Use an nsTArray<nsCString> instead of an nsCStringArray.
- */
-NS_MSG_BASE PRBool ParseString(const nsACString& string, char delimiter, nsCStringArray& array);
-
 #ifdef MOZILLA_1_9_1_BRANCH
 /**
  * Parses a given string using the delimiter passed in. Items parsed from the
  * string will be appended to the array. This version is only used on the
  * MOZILLA_1_9_1_BRANCH as the trunk already has a suitable function.
  *
  * @param string
  *        The string to parse.
--- a/mailnews/compose/src/nsMsgSendLater.cpp
+++ b/mailnews/compose/src/nsMsgSendLater.cpp
@@ -702,22 +702,22 @@ nsresult nsMsgSendLater::SetOrigMsgDispo
   // flags for the original message that this message might be a reply to
   // or forward of.
   nsCString originalMsgURIs;
   nsCString queuedDisposition;
   mMessage->GetStringProperty(ORIG_URI_PROPERTY, getter_Copies(originalMsgURIs));
   mMessage->GetStringProperty(QUEUED_DISPOSITION_PROPERTY, getter_Copies(queuedDisposition));
   if (!queuedDisposition.IsEmpty())
   {
-    nsCStringArray uriArray;
+    nsTArray<nsCString> uriArray;
     ParseString(originalMsgURIs, ',', uriArray);
-    for (PRInt32 i = 0; i < uriArray.Count(); i++)
+    for (PRUint32 i = 0; i < uriArray.Length(); i++)
     {
       nsCOMPtr <nsIMsgDBHdr> msgHdr;
-      nsresult rv = GetMsgDBHdrFromURI(uriArray[i]->get(), getter_AddRefs(msgHdr));
+      nsresult rv = GetMsgDBHdrFromURI(uriArray[i].get(), getter_AddRefs(msgHdr));
       NS_ENSURE_SUCCESS(rv,rv);
       if (msgHdr)
       {
         // get the folder for the message resource
         nsCOMPtr<nsIMsgFolder> msgFolder;
         msgHdr->GetFolder(getter_AddRefs(msgFolder));
         if (msgFolder)
         {
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -3208,23 +3208,23 @@ nsImapProtocol::FetchMessage(const nsCSt
 
       if (!downloadAllHeaders)  // if it's ok -- no filters on any header, etc.
       {
         char *headersToDL = nsnull;
         char *what = nsnull;
         const char *dbHeaders = (gUseEnvelopeCmd) ? IMAP_DB_HEADERS : IMAP_ENV_AND_DB_HEADERS;
         nsCString arbitraryHeaders;
         GetArbitraryHeadersToDownload(arbitraryHeaders);
-        for (PRInt32 i = 0; i < mCustomDBHeaders.Count(); i++)
+        for (PRUint32 i = 0; i < mCustomDBHeaders.Length(); i++)
         {
-          if (arbitraryHeaders.Find(* (mCustomDBHeaders[i]), PR_TRUE) == kNotFound)
+          if (arbitraryHeaders.Find(mCustomDBHeaders[i], PR_TRUE) == kNotFound)
           {
             if (!arbitraryHeaders.IsEmpty())
               arbitraryHeaders.Append(' ');
-            arbitraryHeaders.Append(mCustomDBHeaders[i]->get());
+            arbitraryHeaders.Append(mCustomDBHeaders[i]);
           }
         }
         if (arbitraryHeaders.IsEmpty())
           headersToDL = strdup(dbHeaders);
         else
           headersToDL = PR_smprintf("%s %s",dbHeaders, arbitraryHeaders.get());
 
         if (gUseEnvelopeCmd)
--- a/mailnews/imap/src/nsImapProtocol.h
+++ b/mailnews/imap/src/nsImapProtocol.h
@@ -62,16 +62,17 @@
 
 // UI Thread proxy helper
 #include "nsIImapProtocolSink.h"
 
 #include "nsImapServerResponseParser.h"
 #include "nsImapFlagAndUidState.h"
 #include "nsIMAPNamespace.h"
 #include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "nsWeakPtr.h"
 #include "nsMsgLineBuffer.h" // we need this to use the nsMsgLineStreamBuffer helper class...
 #include "nsIInputStream.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsCOMArray.h"
 #include "nsIThread.h"
 #include "nsIRunnable.h"
 #include "nsIImapMockChannel.h"
@@ -564,17 +565,17 @@ private:
   PRBool m_useCondStore; 
   // these come from the nsIDBFolderInfo in the msgDatabase and
   // are initialized in nsImapProtocol::SetupWithUrl.
   PRUint64 mFolderLastModSeq;
   PRInt32 mFolderTotalMsgCount;
   PRUint32 mFolderHighestUID;
   PRUint32 mFolderNumDeleted;
 
-  nsCStringArray mCustomDBHeaders;
+  nsTArray<nsCString> mCustomDBHeaders;
   PRBool  m_trackingTime;
   PRTime  m_startTime;
   PRTime  m_endTime;
   PRTime  m_lastActiveTime;
   PRInt32 m_tooFastTime;
   PRInt32 m_idealTime;
   PRInt32 m_chunkAddSize;
   PRInt32 m_chunkStartSize;
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -3917,27 +3917,27 @@ nsresult nsMsgLocalMailFolder::ChangeKey
       nsCOMPtr<nsIMsgDBHdr> message = do_QueryElementAt(aMessages, i, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
       PRUint32 messageOffset;
       message->GetMessageOffset(&messageOffset);
       PRUint32 statusOffset = 0;
       (void)message->GetStatusOffset(&statusOffset);
       PRUint32 desiredOffset = messageOffset + statusOffset;
 
-      nsCStringArray keywordArray;
+      nsTArray<nsCString> keywordArray;
       ParseString(aKeywords, ' ', keywordArray);
-      for (PRInt32 j = 0; j < keywordArray.Count(); j++)
+      for (PRUint32 j = 0; j < keywordArray.Length(); j++)
       {
         nsCAutoString header;
         nsCAutoString keywords;
         PRBool done = PR_FALSE;
         PRUint32 len = 0;
         nsCAutoString keywordToWrite(" ");
 
-        keywordToWrite.Append(*(keywordArray[j]));
+        keywordToWrite.Append(keywordArray[j]);
         seekableStream->Seek(nsISeekableStream::NS_SEEK_SET, desiredOffset);
         // need to reset lineBuffer, which is cheaper than creating a new one.
         lineBuffer->start = lineBuffer->end = lineBuffer->buf;
         PRBool inKeywordHeader = PR_FALSE;
         PRBool foundKeyword = PR_FALSE;
         PRUint32 offsetToAddKeyword = 0;
         PRBool more;
         message->GetMessageSize(&len);
@@ -3962,17 +3962,17 @@ nsresult nsMsgLocalMailFolder::ChangeKey
               ; // continuation header line
             else if (inKeywordHeader)
               break;
             else
               continue;
             PRInt32 keywordHdrLength = keywordHeaders.Length();
             PRInt32 startOffset, keywordLength;
             // check if we have the keyword
-            if (MsgFindKeyword(*(keywordArray[j]), keywordHeaders, &startOffset, &keywordLength))
+            if (MsgFindKeyword(keywordArray[j], keywordHeaders, &startOffset, &keywordLength))
             {
               foundKeyword = PR_TRUE;
               if (!add) // if we're removing, remove it, and break;
               {
                 keywordHeaders.Cut(startOffset, keywordLength);
                 for (PRInt32 i = keywordLength; i > 0; i--)
                   keywordHeaders.Append(' ');
                 seekableStream->Seek(nsISeekableStream::NS_SEEK_SET, lineStartPos);
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -522,19 +522,19 @@ nsParseMailMessageState::nsParseMailMess
   m_customDBHeaderValues = nsnull;
   nsCString customDBHeaders;
   nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
   if (pPrefBranch)
   {
      pPrefBranch->GetCharPref("mailnews.customDBHeaders",  getter_Copies(customDBHeaders));
      ToLowerCase(customDBHeaders);
      ParseString(customDBHeaders, ' ', m_customDBHeaders);
-     if (m_customDBHeaders.Count())
+     if (m_customDBHeaders.Length())
      {
-       m_customDBHeaderValues = new struct message_header [m_customDBHeaders.Count()];
+       m_customDBHeaderValues = new struct message_header [m_customDBHeaders.Length()];
        if (!m_customDBHeaderValues)
          m_customDBHeaders.Clear();
      }
   }
   Clear();
   m_HeaderAddressParser = do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID);
 }
 
@@ -579,17 +579,17 @@ NS_IMETHODIMP nsParseMailMessageState::C
   m_body_lines = 0;
   m_newMsgHdr = nsnull;
   m_envelope_pos = 0;
   ClearAggregateHeader (m_toList);
   ClearAggregateHeader (m_ccList);
   m_headers.ResetWritePos();
   m_envelope.ResetWritePos();
   m_receivedTime = LL_ZERO;
-  for (PRInt32 i = 0; i < m_customDBHeaders.Count(); i++)
+  for (PRUint32 i = 0; i < m_customDBHeaders.Length(); i++)
     m_customDBHeaderValues[i].length = 0;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsParseMailMessageState::SetState(nsMailboxParseState aState)
 {
   m_state = aState;
@@ -1011,17 +1011,17 @@ int nsParseMailMessageState::ParseHeader
       else if (!PL_strncasecmp("X-Priority", buf, end - buf)
         || !PL_strncasecmp("Priority", buf, end - buf))
         header = &m_priority;
       else if (!PL_strncasecmp(HEADER_X_MOZILLA_KEYWORDS, buf, end - buf)
         && !m_keywords.length)
         header = &m_keywords;
       break;
     }
-    if (!header && m_customDBHeaders.Count())
+    if (!header && m_customDBHeaders.Length())
     {
       nsDependentCSubstring headerStr(buf, end);
 
       ToLowerCase(headerStr);
       PRInt32 customHeaderIndex = m_customDBHeaders.IndexOf(headerStr);
       if (customHeaderIndex != kNotFound)
         header = & m_customDBHeaderValues[customHeaderIndex];
     }
@@ -1534,35 +1534,35 @@ int nsParseMailMessageState::FinalizeHea
         else if (priorityFlags == nsMsgPriority::notSet)
           m_newMsgHdr->SetPriority(nsMsgPriority::none);
         if (keywords)
         {
           // When there are many keywords, some may not have been written
           // to the message file, so add extra keywords from the backup
           nsCAutoString oldKeywords;
           m_newMsgHdr->GetStringProperty("keywords", getter_Copies(oldKeywords));
-          nsCStringArray newKeywordArray, oldKeywordArray;
+          nsTArray<nsCString> newKeywordArray, oldKeywordArray;
           ParseString(Substring(keywords->value, keywords->value + keywords->length), ' ', newKeywordArray);
           ParseString(oldKeywords, ' ', oldKeywordArray);
-          for (PRInt32 i = 0; i < oldKeywordArray.Count(); i++)
-            if (newKeywordArray.IndexOf(*oldKeywordArray.CStringAt(i)) < 0)
-              newKeywordArray.AppendCString(*oldKeywordArray.CStringAt(i));
+          for (PRUint32 i = 0; i < oldKeywordArray.Length(); i++)
+            if (!newKeywordArray.Contains(oldKeywordArray[i]))
+              newKeywordArray.AppendElement(oldKeywordArray[i]);
           nsCAutoString newKeywords;
-          for (PRInt32 i = 0; i < newKeywordArray.Count(); i++)
+          for (PRUint32 i = 0; i < newKeywordArray.Length(); i++)
           {
             if (i)
               newKeywords.Append(" ");
-            newKeywords.Append(*newKeywordArray.CStringAt(i));
+            newKeywords.Append(newKeywordArray[i]);
           }
           m_newMsgHdr->SetStringProperty("keywords", newKeywords.get());
         }
-        for (PRInt32 i = 0; i < m_customDBHeaders.Count(); i++)
+        for (PRUint32 i = 0; i < m_customDBHeaders.Length(); i++)
         {
           if (m_customDBHeaderValues[i].length)
-            m_newMsgHdr->SetStringProperty((m_customDBHeaders[i])->get(), m_customDBHeaderValues[i].value);
+            m_newMsgHdr->SetStringProperty(m_customDBHeaders[i].get(), m_customDBHeaderValues[i].value);
         }
         if (content_type)
         {
           char *substring = PL_strstr(content_type->value, "charset");
           if (substring)
           {
             char *charset = PL_strchr (substring, '=');
             if (charset)
--- a/mailnews/local/src/nsParseMailbox.h
+++ b/mailnews/local/src/nsParseMailbox.h
@@ -147,17 +147,17 @@ public:
   PRTime m_receivedTime;
   PRUint16              m_body_lines;
 
   PRBool                m_IgnoreXMozillaStatus;
 
   // this enables extensions to add the values of particular headers to
   // the .msf file as properties of nsIMsgHdr. It is initialized from a
   // pref, mailnews.customDBHeaders
-  nsCStringArray        m_customDBHeaders;
+  nsTArray<nsCString>   m_customDBHeaders;
   struct message_header *m_customDBHeaderValues;
 protected:
 };
 
 // this should go in some utility class.
 inline int nsParseMailMessageState::msg_UnHex(char C)
 {
   return ((C >= '0' && C <= '9') ? C - '0' :
--- a/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp
+++ b/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp
@@ -195,17 +195,17 @@ nsresult nsMimeHtmlDisplayEmitter::Broad
 {
   // two string enumerators to pass out to the header sink
   nsRefPtr<nsMimeStringEnumerator> headerNameEnumerator = new nsMimeStringEnumerator();
   NS_ENSURE_TRUE(headerNameEnumerator, NS_ERROR_OUT_OF_MEMORY);
   nsRefPtr<nsMimeStringEnumerator> headerValueEnumerator = new nsMimeStringEnumerator();
   NS_ENSURE_TRUE(headerValueEnumerator, NS_ERROR_OUT_OF_MEMORY);
 
   nsCString extraExpandedHeaders;
-  nsCStringArray extraExpandedHeadersArray;
+  nsTArray<nsCString> extraExpandedHeadersArray;
   nsCAutoString convertedDateString;
 
   PRBool displayOriginalDate = PR_FALSE;
   nsresult rv;
   nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   if (pPrefBranch)
   {
     pPrefBranch->GetBoolPref("mailnews.display.original_date", &displayOriginalDate);
@@ -238,17 +238,17 @@ nsresult nsMimeHtmlDisplayEmitter::Broad
           PL_strcasecmp("reply-to", headerInfo->name) && PL_strcasecmp("subject", headerInfo->name) &&
           PL_strcasecmp("organization", headerInfo->name) && PL_strcasecmp("user-agent", headerInfo->name) &&
           PL_strcasecmp("content-base", headerInfo->name) && PL_strcasecmp("sender", headerInfo->name) &&
           PL_strcasecmp("date", headerInfo->name) && PL_strcasecmp("x-mailer", headerInfo->name) &&
           PL_strcasecmp("content-type", headerInfo->name) && PL_strcasecmp("message-id", headerInfo->name) &&
           PL_strcasecmp("x-newsreader", headerInfo->name) && PL_strcasecmp("x-mimeole", headerInfo->name) &&
           PL_strcasecmp("references", headerInfo->name) && PL_strcasecmp("in-reply-to", headerInfo->name) &&
           // make headerStr lower case because IndexOf is case-sensitive
-         (!extraExpandedHeadersArray.Count() || (ToLowerCase(headerStr),
+         (!extraExpandedHeadersArray.Length() || (ToLowerCase(headerStr),
             extraExpandedHeadersArray.IndexOf(headerStr) == -1)))
             continue;
     }
 
     if (!PL_strcasecmp("Date", headerInfo->name) && !displayOriginalDate)
     {
       GenerateDateString(headerValue, convertedDateString);
       headerValueEnumerator->Append(convertedDateString);
--- a/mailnews/mime/src/mimei.h
+++ b/mailnews/mime/src/mimei.h
@@ -224,17 +224,17 @@
       }
 
   If you write a libmime content type handler, libmime might create several
   instances of your class at once and call e.g. the same finalize code for
   3 different objects in a row.
  */
 
 #include "mimehdrs.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 
 typedef struct MimeObject      MimeObject;
 typedef struct MimeObjectClass MimeObjectClass;
 
 #ifdef ENABLE_SMIME
 class nsICMSMessage;
 #endif // ENABLE_SMIME
 
@@ -399,18 +399,18 @@ public:
 
   PRBool first_data_written_p;  /* State used for Mozilla lazy-stream-
                    creation evilness. */
 
   PRBool decrypted_p; /* If options->dexlate_p is true, then this
                         will be set to indicate whether any
                         dexlateion did in fact occur.
                       */
-  nsCStringArray partsToStrip;      /* if we're stripping parts, what parts to strip */
-  nsCStringArray detachToFiles;      /* if we're detaching parts, where each part was detached to */
+  nsTArray<nsCString> partsToStrip; /* if we're stripping parts, what parts to strip */
+  nsTArray<nsCString> detachToFiles; /* if we're detaching parts, where each part was detached to */
   PRBool strippingPart;
   nsCString detachedFilePath;       /* if we've detached this part, filepath of detached part */
 };
 
 
 
 /* Some output-generation utility functions...
  */
--- a/mailnews/mime/src/mimemult.cpp
+++ b/mailnews/mime/src/mimemult.cpp
@@ -193,32 +193,32 @@ MimeMultipart_parse_line (const char *li
       
       /* Reset the header parser for this upcoming part. */
       PR_ASSERT(!mult->hdrs);
       if (mult->hdrs)
         MimeHeaders_free(mult->hdrs);
       mult->hdrs = MimeHeaders_new();
       if (!mult->hdrs)
         return MIME_OUT_OF_MEMORY;
-      if (obj->options->state->partsToStrip.Count() > 0)
+      if (obj->options->state->partsToStrip.Length() > 0)
       {
         nsCAutoString newPart(mime_part_address(obj));
         MimeContainer *container = (MimeContainer*) obj; 
         newPart.Append('.');
         newPart.AppendInt(container->nchildren + 1);
         obj->options->state->strippingPart = PR_FALSE;
         // check if this is a sub-part of a part we're stripping.
-        for (PRInt32 partIndex = 0; partIndex < obj->options->state->partsToStrip.Count(); partIndex++)
+        for (PRUint32 partIndex = 0; partIndex < obj->options->state->partsToStrip.Length(); partIndex++)
         {
-          nsCString *curPartToStrip = obj->options->state->partsToStrip.CStringAt(partIndex);
-          if (newPart.Find(*curPartToStrip) == 0 && (newPart.Length() == curPartToStrip->Length() || newPart.CharAt(curPartToStrip->Length()) == '.'))
+          nsCString &curPartToStrip = obj->options->state->partsToStrip[partIndex];
+          if (newPart.Find(curPartToStrip) == 0 && (newPart.Length() == curPartToStrip.Length() || newPart.CharAt(curPartToStrip.Length()) == '.'))
           {
             obj->options->state->strippingPart = PR_TRUE;
-            if (partIndex < obj->options->state->detachToFiles.Count())
-              obj->options->state->detachedFilePath = *obj->options->state->detachToFiles.CStringAt(partIndex);
+            if (partIndex < obj->options->state->detachToFiles.Length())
+              obj->options->state->detachedFilePath = obj->options->state->detachToFiles[partIndex];
             break;
           }
         }
       }
     }
     
     // if stripping out attachments, write the boundary line. Otherwise, return
     // to ignore it.
--- a/mailnews/news/src/nsNNTPNewsgroupList.cpp
+++ b/mailnews/news/src/nsNNTPNewsgroupList.cpp
@@ -145,24 +145,24 @@ nsNNTPNewsgroupList::Initialize(nsINntpU
   rv = folder->GetServer(getter_AddRefs(server));
   NS_ENSURE_SUCCESS(rv,rv);
 
   rv = server->GetFilterList(m_msgWindow, getter_AddRefs(m_serverFilterList));
   NS_ENSURE_SUCCESS(rv,rv);
   nsCAutoString servHeaders;
   m_serverFilterList->GetArbitraryHeaders(servHeaders);
 
-  nsCStringArray servArray;
+  nsTArray<nsCString> servArray;
   ParseString(servHeaders, ' ', servArray);
 
   // servArray may have duplicates already in m_filterHeaders.
-  for (PRInt32 i = 0; i < servArray.Count(); i++)
+  for (PRUint32 i = 0; i < servArray.Length(); i++)
   {
-    if (m_filterHeaders.IndexOf(*(servArray[i])) == -1)
-      m_filterHeaders.AppendCString(*(servArray[i]));
+    if (m_filterHeaders.IndexOf(servArray[i]) == -1)
+      m_filterHeaders.AppendElement(servArray[i]);
   }
   return NS_OK;
 }
 
 nsresult
 nsNNTPNewsgroupList::CleanUp()
 {
   // here we make sure that there aren't missing articles in the unread set
@@ -926,20 +926,20 @@ nsNNTPNewsgroupList::FinishXOVERLINE(int
     *newstatus=0;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNNTPNewsgroupList::InitXHDR(nsACString &header)
 {
-  if (++m_currentXHDRIndex >= m_filterHeaders.Count())
+  if (++m_currentXHDRIndex >= m_filterHeaders.Length())
     header.Truncate();
   else
-    header.Assign(*m_filterHeaders[m_currentXHDRIndex]);
+    header.Assign(m_filterHeaders[m_currentXHDRIndex]);
   // Don't include these in our XHDR bouts, as they are already provided through
   // XOVER. 
   if (header.EqualsLiteral("message-id") ||
       header.EqualsLiteral("references"))
     return InitXHDR(header);
   return NS_OK;
 }
 
@@ -964,17 +964,17 @@ nsNNTPNewsgroupList::ProcessXHDRLine(con
     return NS_ERROR_FAILURE;
   // RFC 2980 specifies one or more spaces.
   value.Trim(" ");
 
   nsCOMPtr <nsIMsgDBHdr> header;
   nsresult rv = m_newsDB->GetMsgHdrForKey(number, getter_AddRefs(header));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = header->SetStringProperty(m_filterHeaders[m_currentXHDRIndex]->get(), value.get());
+  rv = header->SetStringProperty(m_filterHeaders[m_currentXHDRIndex].get(), value.get());
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRInt32 totalToDownload = m_lastMsgToDownload - m_firstMsgToDownload + 1;
   PRInt32 numDownloaded = number - m_firstMsgNumber + 1;
 
   PRTime elapsedTime = PR_Now() - m_lastStatusUpdate;
 
   if (elapsedTime > MIN_STATUS_UPDATE_INTERVAL)
@@ -1181,24 +1181,24 @@ nsNNTPNewsgroupList::CallFilters()
 
     if (!(subject.IsEmpty()))
     {
       fullHeaders.AppendLiteral(SUBJECT_HEADER);
       fullHeaders += subject;
       fullHeaders += '\0';
     }
 
-    for (PRInt32 header = 0; header < m_filterHeaders.Count(); header++)
+    for (PRUint32 header = 0; header < m_filterHeaders.Length(); header++)
     {
       nsCString retValue;
-      m_newMsgHdr->GetStringProperty(m_filterHeaders[header]->get(),
+      m_newMsgHdr->GetStringProperty(m_filterHeaders[header].get(),
                                      getter_Copies(retValue));
       if (!retValue.IsEmpty())
       {
-        fullHeaders += *(m_filterHeaders[header]);
+        fullHeaders += m_filterHeaders[header];
         fullHeaders.AppendLiteral(": ");
         fullHeaders += retValue;
         fullHeaders += '\0';
       }
     }
 
     // The per-newsgroup filters should go first. If something stops filter
     // execution, then users should be able to override the global filters in
@@ -1262,17 +1262,17 @@ nsNNTPNewsgroupList::SetProgressStatus(c
     }
   }
 }
 
 void
 nsNNTPNewsgroupList::UpdateStatus(PRBool filtering, PRInt32 numDLed, PRInt32 totToDL)
 {
   PRInt32 numerator = (filtering ? m_currentXHDRIndex + 1 : 1) * numDLed;
-  PRInt32 denominator = (m_filterHeaders.Count() + 1) * totToDL;
+  PRInt32 denominator = (m_filterHeaders.Length() + 1) * totToDL;
   PRInt32 percent = numerator * 100 / denominator;
   
   nsAutoString numDownloadedStr;
   numDownloadedStr.AppendInt(numDLed);
 
   nsAutoString totalToDownloadStr;
   totalToDownloadStr.AppendInt(totToDL);
 
@@ -1284,17 +1284,17 @@ nsNNTPNewsgroupList::UpdateStatus(PRBool
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
   if (!NS_SUCCEEDED(rv))
     return;
 
   if (filtering)
   {
-    NS_ConvertUTF8toUTF16 header(*m_filterHeaders[m_currentXHDRIndex]);
+    NS_ConvertUTF8toUTF16 header(m_filterHeaders[m_currentXHDRIndex]);
     const PRUnichar *formatStrings[3] = { header.get(),
       numDownloadedStr.get(), totalToDownloadStr.get() };
     rv = bundle->FormatStringFromName(NS_LITERAL_STRING("downloadingFilterHeaders").get(),
       formatStrings, 3, getter_Copies(statusString));
   }
   else
   {
     const PRUnichar *formatStrings[2] = { numDownloadedStr.get(),
--- a/mailnews/news/src/nsNNTPNewsgroupList.h
+++ b/mailnews/news/src/nsNNTPNewsgroupList.h
@@ -49,16 +49,17 @@
 #include "nsIMsgNewsFolder.h"
 #include "nsIMsgDatabase.h"
 #include "nsMsgKeySet.h"
 #include "nsINntpUrl.h"
 #include "nsIMsgFilterList.h"
 #include "nsIMsgHdr.h"
 #include "nsIMsgWindow.h"
 #include "nsCOMArray.h"
+#include "nsTArray.h"
 
 /* The below is all stuff that we remember for netlib about which
    articles we've already seen in the current newsgroup. */
 
 typedef struct MSG_NewsKnown {
   nsMsgKeySet* set; /* Set of articles we've already gotten
                        from the newsserver (if it's marked
                        "read", then we've already gotten it).
@@ -130,18 +131,18 @@ protected:
   /**
    * The endpoints of the message chunk we are capable of downloading.
    */
   PRInt32 m_firstMsgToDownload, m_lastMsgToDownload;
   
   struct MSG_NewsKnown m_knownArts;
   nsMsgKeySet *m_set;
 
-  nsCStringArray m_filterHeaders;
-  PRInt32 m_currentXHDRIndex;
+  nsTArray<nsCString> m_filterHeaders;
+  PRUint32 m_currentXHDRIndex;
   nsCString m_lastHeader;
   nsCString m_thisLine;
 
 private:
   nsCOMPtr <nsIMsgWindow> m_msgWindow;
   nsCOMPtr <nsIMsgFilterList> m_filterList;
   nsCOMPtr <nsIMsgFilterList> m_serverFilterList;
   nsCOMPtr <nsIMsgDBHdr> m_newMsgHdr; // current message header we're building
--- a/mailnews/news/src/nsNntpService.cpp
+++ b/mailnews/news/src/nsNntpService.cpp
@@ -839,39 +839,39 @@ nsNntpService::GenerateNewsHeaderValsFor
   //
   // we are not going to allow the user to cross post to multiple hosts.
   // if we detect that, we stop and return error.
 
   nsCAutoString host;
   nsCAutoString str;
   nsCAutoString newsgroups;
 
-  nsCStringArray list;
+  nsTArray<nsCString> list;
   ParseString(newsgroupsList, ',', list);
-  for (PRInt32 index = 0; index < list.Count(); index++)
+  for (PRUint32 index = 0; index < list.Length(); index++)
   {
-    list[index]->StripWhitespace();
-    if (!list[index]->IsEmpty())
+    list[index].StripWhitespace();
+    if (!list[index].IsEmpty())
     {
       nsCAutoString currentHost;
       nsCAutoString theRest;
       // does str start with "news:/"?
-      if (StringBeginsWith(*list[index], NS_LITERAL_CSTRING(kNewsRootURI)))
+      if (StringBeginsWith(list[index], NS_LITERAL_CSTRING(kNewsRootURI)))
       {
         // we have news://group or news://host/group
         // set theRest to what's after news://
-        list[index]->Right(theRest, list[index]->Length() - kNewsRootURILen /* for news:/ */ - 1 /* for the slash */);
+        list[index].Right(theRest, list[index].Length() - kNewsRootURILen /* for news:/ */ - 1 /* for the slash */);
       }
-      else if (list[index]->Find(":/") != -1)
+      else if (list[index].Find(":/") != -1)
       {
         // we have x:/y where x != news. this is bad, return failure
         return NS_ERROR_FAILURE;
       }
       else
-        theRest = *list[index];
+        theRest = list[index];
 
       // theRest is "group" or "host/group"
       PRInt32 slashpos = theRest.FindChar('/');
       if (slashpos > 0 )
       {
         nsCAutoString currentGroup;
 
         // theRest is "host/group"
@@ -893,17 +893,17 @@ nsNntpService::GenerateNewsHeaderValsFor
       {
         // str is "group"
         rv = FindHostFromGroup(currentHost, str);
         if (NS_FAILED(rv))
           return rv;
         // build up the newsgroups
         if (!newsgroups.IsEmpty())
           newsgroups += ",";
-        newsgroups += *list[index];
+        newsgroups += list[index];
       }
 
       if (!currentHost.IsEmpty())
       {
         if (host.IsEmpty())
           host = currentHost;
         else
         {