Bug 693949 - Drop nsCStringArray. r=bsmedberg
authorMark Banner <bugzilla@standard8.plus.com>
Fri, 28 Oct 2011 08:35:45 +0100
changeset 80712 fcf252e6ce4a49d6fbecdd6dec47dc574a43010c
parent 80711 b79b68029f1de7fd719afdc8b93342957c6d414c
child 80713 64e10f2dfc60cda2763f62605bca60b833950e7d
push id434
push userclegnitto@mozilla.com
push dateWed, 21 Dec 2011 12:10:54 +0000
treeherdermozilla-beta@bddb6ed8dd47 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs693949
milestone10.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 693949 - Drop nsCStringArray. r=bsmedberg
content/base/public/nsIXPathEvaluatorInternal.h
content/xbl/src/nsXBLResourceLoader.cpp
content/xul/templates/src/nsXULTemplateResultStorage.cpp
docshell/shistory/src/nsSHEntryShared.h
dom/system/nsDeviceMotion.h
dom/system/unix/nsDeviceMotionSystem.h
layout/style/nsCSSParser.cpp
layout/style/nsCSSParser.h
layout/style/nsCSSStyleSheet.h
layout/style/nsDOMCSSValueList.h
toolkit/components/downloads/nsDownloadManager.h
toolkit/components/places/nsAnnotationService.h
widget/src/qt/nsFilePicker.h
xpcom/base/nsMemoryReporterManager.h
xpcom/glue/nsVoidArray.cpp
xpcom/glue/nsVoidArray.h
--- a/content/base/public/nsIXPathEvaluatorInternal.h
+++ b/content/base/public/nsIXPathEvaluatorInternal.h
@@ -36,16 +36,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
  
 #ifndef nsIXPathEvaluatorInternal_h__
 #define nsIXPathEvaluatorInternal_h__
 
 #include "nsCOMArray.h"
 #include "nsTArray.h"
+#include "nsString.h"
 
 class nsIDOMDocument;
 class nsIDOMXPathExpression;
 class nsIDOMXPathNSResolver;
 
 #define NS_IXPATHEVALUATORINTERNAL_IID \
   {0xb4b72daa, 0x65d6, 0x440f, \
     { 0xb6, 0x08, 0xe2, 0xee, 0x9a, 0x82, 0xf3, 0x13 }}
--- a/content/xbl/src/nsXBLResourceLoader.cpp
+++ b/content/xbl/src/nsXBLResourceLoader.cpp
@@ -31,16 +31,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "nsTArray.h"
+#include "nsString.h"
 #include "nsCSSStyleSheet.h"
 #include "nsIStyleRuleProcessor.h"
 #include "nsIDocument.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsIXBLService.h"
 #include "nsIServiceManager.h"
 #include "nsXBLResourceLoader.h"
--- a/content/xul/templates/src/nsXULTemplateResultStorage.cpp
+++ b/content/xul/templates/src/nsXULTemplateResultStorage.cpp
@@ -33,17 +33,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIServiceManager.h"
 #include "nsRDFCID.h"
 #include "nsIRDFService.h"
-
+#include "nsString.h"
 #include "nsXULTemplateResultStorage.h"
 
 static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
 
 NS_IMPL_ISUPPORTS1(nsXULTemplateResultStorage, nsIXULTemplateResult)
 
 nsXULTemplateResultStorage::nsXULTemplateResultStorage(nsXULTemplateResultSetStorage* aResultSet)
 {
--- a/docshell/shistory/src/nsSHEntryShared.h
+++ b/docshell/shistory/src/nsSHEntryShared.h
@@ -40,16 +40,17 @@
 
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsCOMArray.h"
 #include "nsIBFCacheEntry.h"
 #include "nsIMutationObserver.h"
 #include "nsExpirationTracker.h"
 #include "nsRect.h"
+#include "nsString.h"
 
 class nsSHEntry;
 class nsISHEntry;
 class nsIDocument;
 class nsIContentViewer;
 class nsIDocShellTreeItem;
 class nsILayoutHistoryState;
 class nsISupportsArray;
--- a/dom/system/nsDeviceMotion.h
+++ b/dom/system/nsDeviceMotion.h
@@ -35,16 +35,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsDeviceMotion_h
 #define nsDeviceMotion_h
 
 #include "nsIDeviceMotion.h"
 #include "nsIDOMDeviceMotionEvent.h"
 #include "nsCOMArray.h"
+#include "nsTArray.h"
 #include "nsCOMPtr.h"
 #include "nsITimer.h"
 
 #define NS_DEVICE_MOTION_CID \
 { 0xecba5203, 0x77da, 0x465a, \
 { 0x86, 0x5e, 0x78, 0xb7, 0xaf, 0x10, 0xd8, 0xf7 } }
 
 #define NS_DEVICE_MOTION_CONTRACTID "@mozilla.org/devicemotion;1"
--- a/dom/system/unix/nsDeviceMotionSystem.h
+++ b/dom/system/unix/nsDeviceMotionSystem.h
@@ -34,16 +34,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsDeviceMotionSystem_h
 #define nsDeviceMotionSystem_h
 
 #include <unistd.h>
+#include <stdio.h>
 #include "nsDeviceMotion.h"
 
 enum nsAccelerometerSystemDriver
 {
   eNoSensor,
   eAppleSensor,
   eIBMSensor,
   eMaemoSensor,
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -50,16 +50,17 @@
 #include "nsCSSProps.h"
 #include "nsCSSKeywords.h"
 #include "nsCSSScanner.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/css/StyleRule.h"
 #include "mozilla/css/ImportRule.h"
 #include "nsCSSRules.h"
 #include "mozilla/css/NameSpaceRule.h"
+#include "nsTArray.h"
 #include "nsCSSStyleSheet.h"
 #include "mozilla/css/Declaration.h"
 #include "nsStyleConsts.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
@@ -78,17 +79,16 @@
 #include "mozilla/LookAndFeel.h"
 #include "nsStyleUtil.h"
 #include "nsIPrincipal.h"
 #include "prprf.h"
 #include "math.h"
 #include "nsContentUtils.h"
 #include "nsDOMError.h"
 #include "nsAutoPtr.h"
-#include "nsTArray.h"
 #include "prlog.h"
 #include "CSSCalc.h"
 #include "nsMediaFeatures.h"
 #include "nsLayoutUtils.h"
 
 #include "mozilla/Util.h"
 
 using namespace mozilla;
--- a/layout/style/nsCSSParser.h
+++ b/layout/style/nsCSSParser.h
@@ -40,16 +40,17 @@
 #ifndef nsCSSParser_h___
 #define nsCSSParser_h___
 
 #include "nsAString.h"
 #include "nsCSSProperty.h"
 #include "nsColor.h"
 #include "nsCOMArray.h"
 #include "nsCOMPtr.h"
+#include "nsTArray.h"
 
 class nsCSSStyleSheet;
 class nsIPrincipal;
 class nsIURI;
 struct nsCSSSelectorList;
 class nsMediaList;
 class nsCSSKeyframeRule;
 
--- a/layout/style/nsCSSStyleSheet.h
+++ b/layout/style/nsCSSStyleSheet.h
@@ -46,16 +46,18 @@
 
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsIStyleSheet.h"
 #include "nsIDOMCSSStyleSheet.h"
 #include "nsICSSLoaderObserver.h"
 #include "nsCOMArray.h"
+#include "nsTArray.h"
+#include "nsString.h"
 
 class nsXMLNameSpaceMap;
 class nsCSSRuleProcessor;
 class nsMediaList;
 class nsIPrincipal;
 class nsIURI;
 class nsMediaList;
 class nsMediaQueryResultCacheKey;
--- a/layout/style/nsDOMCSSValueList.h
+++ b/layout/style/nsDOMCSSValueList.h
@@ -37,17 +37,18 @@
 
 /* DOM object representing lists of values in DOM computed style */
 
 #ifndef nsDOMCSSValueList_h___
 #define nsDOMCSSValueList_h___
 
 #include "nsIDOMCSSValue.h"
 #include "nsIDOMCSSValueList.h"
-#include "nsCOMArray.h"
+#include "nsTArray.h"
+
 
 #include "nsCOMPtr.h"
 
 class nsDOMCSSValueList : public nsIDOMCSSValueList
 {
 public:
   NS_DECL_ISUPPORTS
 
--- a/toolkit/components/downloads/nsDownloadManager.h
+++ b/toolkit/components/downloads/nsDownloadManager.h
@@ -54,16 +54,17 @@
 #include "nsILocalFile.h"
 #include "nsIMIMEInfo.h"
 #include "nsINavHistoryService.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIStringBundle.h"
 #include "nsISupportsPrimitives.h"
 #include "nsITimer.h"
+#include "nsString.h"
 
 #include "mozStorageHelper.h"
 #include "nsAutoPtr.h"
 #include "nsCOMArray.h"
 
 typedef PRInt16 DownloadState;
 typedef PRInt16 DownloadType;
 
--- a/toolkit/components/places/nsAnnotationService.h
+++ b/toolkit/components/places/nsAnnotationService.h
@@ -43,16 +43,17 @@
 #include "nsIAnnotationService.h"
 #include "nsTArray.h"
 #include "nsCOMArray.h"
 #include "nsCOMPtr.h"
 #include "nsServiceManagerUtils.h"
 #include "nsWeakReference.h"
 #include "nsToolkitCompsCID.h"
 #include "Database.h"
+#include "nsString.h"
 
 class nsAnnotationService : public nsIAnnotationService
                           , public nsIObserver
                           , public nsSupportsWeakReference
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIANNOTATIONSERVICE
--- a/widget/src/qt/nsFilePicker.h
+++ b/widget/src/qt/nsFilePicker.h
@@ -38,16 +38,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 #ifndef NSFILEPICKER_H
 #define NSFILEPICKER_H
 
 #include <QPointer>
 #include "nsBaseFilePicker.h"
 #include "nsCOMArray.h"
+#include "nsString.h"
 
 class QFileDialog;
 
 class nsFilePicker : public nsBaseFilePicker
 {
 public:
     nsFilePicker();
 
--- a/xpcom/base/nsMemoryReporterManager.h
+++ b/xpcom/base/nsMemoryReporterManager.h
@@ -1,12 +1,13 @@
 
 #include "nsIMemoryReporter.h"
 #include "nsCOMArray.h"
 #include "mozilla/Mutex.h"
+#include "nsString.h"
 
 using mozilla::Mutex;
 
 class nsMemoryReporter : public nsIMemoryReporter
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMEMORYREPORTER
--- a/xpcom/glue/nsVoidArray.cpp
+++ b/xpcom/glue/nsVoidArray.cpp
@@ -36,17 +36,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include <stdlib.h>
 
 #include "nsVoidArray.h"
 #include "nsQuickSort.h"
 #include "prbit.h"
 #include "nsISupportsImpl.h" // for nsTraceRefcnt
-#include "nsCRTGlue.h"
+#include "nsAlgorithm.h"
 
 /**
  * Grow the array by at least this many elements at a time.
  */
 static const PRInt32 kMinGrowArrayBy = 8;
 static const PRInt32 kMaxGrowArrayBy = 1024;
 static const PRInt32 kAutoClearCompactSizeFactor = 4;
 
@@ -752,282 +752,16 @@ nsAutoVoidArray::nsAutoVoidArray()
   // but we'll clear it at that time if needed to save CPU cycles.
 #if DEBUG_VOIDARRAY
   mIsAuto = true;
   ADD_TO_STATS(MaxAuto,0);
 #endif
   ResetToAutoBuffer();
 }
 
-//----------------------------------------------------------------
-// nsCStringArray
-
-nsCStringArray::nsCStringArray(void)
-  : nsVoidArray()
-{
-}
-
-nsCStringArray::nsCStringArray(PRInt32 aCount)
-  : nsVoidArray(aCount)
-{
-}
-
-nsCStringArray::~nsCStringArray(void)
-{
-  Clear();
-}
-
-nsCStringArray& 
-nsCStringArray::operator=(const nsCStringArray& other)
-{
-  if (this == &other)
-  {
-    return *this;
-  }
-
-  // Free our strings
-  Clear();
-  
-  // Copy the pointers
-  nsVoidArray::operator=(other);
-
-  // Now copy the strings
-  PRInt32 count = Count();
-  for (PRInt32 i = 0; i < count; ++i)
-  {
-    nsCString* oldString = static_cast<nsCString*>(other.ElementAt(i));
-    nsCString* newString = new nsCString(*oldString);
-    if (!newString)
-    {
-      mImpl->mCount = i;
-      return *this;
-    }
-    mImpl->mArray[i] = newString;
-  }
-
-  return *this;
-}
-
-void 
-nsCStringArray::CStringAt(PRInt32 aIndex, nsACString& aCString) const
-{
-  nsCString* string = static_cast<nsCString*>(nsVoidArray::ElementAt(aIndex));
-  if (nsnull != string)
-  {
-    aCString = *string;
-  }
-  else
-  {
-    aCString.Truncate();
-  }
-}
-
-nsCString*
-nsCStringArray::CStringAt(PRInt32 aIndex) const
-{
-  return static_cast<nsCString*>(nsVoidArray::ElementAt(aIndex));
-}
-
-PRInt32 
-nsCStringArray::IndexOf(const nsACString& aPossibleString) const
-{
-  if (mImpl)
-  {
-    void** ap = mImpl->mArray;
-    void** end = ap + mImpl->mCount;
-    while (ap < end)
-    {
-      nsCString* string = static_cast<nsCString*>(*ap);
-      if (string->Equals(aPossibleString))
-      {
-        return ap - mImpl->mArray;
-      }
-      ap++;
-    }
-  }
-  return -1;
-}
-
-#ifdef MOZILLA_INTERNAL_API
-PRInt32 
-nsCStringArray::IndexOfIgnoreCase(const nsACString& aPossibleString) const
-{
-  if (mImpl)
-  {
-    void** ap = mImpl->mArray;
-    void** end = ap + mImpl->mCount;
-    while (ap < end)
-    {
-      nsCString* string = static_cast<nsCString*>(*ap);
-      if (string->Equals(aPossibleString, nsCaseInsensitiveCStringComparator()))
-      {
-        return ap - mImpl->mArray;
-      }
-      ap++;
-    }
-  }
-  return -1;
-}
-#endif
-
-bool 
-nsCStringArray::InsertCStringAt(const nsACString& aCString, PRInt32 aIndex)
-{
-  nsCString* string = new nsCString(aCString);
-  if (!string)
-    return false;
-  if (nsVoidArray::InsertElementAt(string, aIndex))
-    return true;
-
-  delete string;
-  return false;
-}
-
-bool
-nsCStringArray::ReplaceCStringAt(const nsACString& aCString, PRInt32 aIndex)
-{
-  nsCString* string = static_cast<nsCString*>(nsVoidArray::ElementAt(aIndex));
-  if (nsnull != string)
-  {
-    *string = aCString;
-    return true;
-  }
-  return false;
-}
-
-bool 
-nsCStringArray::RemoveCString(const nsACString& aCString)
-{
-  PRInt32 index = IndexOf(aCString);
-  if (-1 < index)
-  {
-    return RemoveCStringAt(index);
-  }
-  return false;
-}
-
-#ifdef MOZILLA_INTERNAL_API
-bool 
-nsCStringArray::RemoveCStringIgnoreCase(const nsACString& aCString)
-{
-  PRInt32 index = IndexOfIgnoreCase(aCString);
-  if (-1 < index)
-  {
-    return RemoveCStringAt(index);
-  }
-  return false;
-}
-#endif
-
-bool nsCStringArray::RemoveCStringAt(PRInt32 aIndex)
-{
-  nsCString* string = CStringAt(aIndex);
-  if (nsnull != string)
-  {
-    nsVoidArray::RemoveElementAt(aIndex);
-    delete string;
-    return true;
-  }
-  return false;
-}
-
-void 
-nsCStringArray::Clear(void)
-{
-  PRInt32 index = Count();
-  while (0 <= --index)
-  {
-    nsCString* string = static_cast<nsCString*>(mImpl->mArray[index]);
-    delete string;
-  }
-  nsVoidArray::Clear();
-}
-
-static int
-CompareCString(const nsCString* aCString1, const nsCString* aCString2, void*)
-{
-#ifdef MOZILLA_INTERNAL_API
-  return Compare(*aCString1, *aCString2);
-#else
-  const char* s1;
-  const char* s2;
-  PRUint32 len1 = NS_CStringGetData(*aCString1, &s1);
-  PRUint32 len2 = NS_CStringGetData(*aCString2, &s2);
-  int r = memcmp(s1, s2, NS_MIN(len1, len2));
-  if (r)
-    return r;
-
-  if (len1 < len2)
-    return -1;
-
-  if (len1 > len2)
-    return 1;
-
-  return 0;
-#endif
-}
-
-#ifdef MOZILLA_INTERNAL_API
-static int
-CompareCStringIgnoreCase(const nsCString* aCString1, const nsCString* aCString2, void*)
-{
-  return Compare(*aCString1, *aCString2, nsCaseInsensitiveCStringComparator());
-}
-#endif
-
-void nsCStringArray::Sort(void)
-{
-  Sort(CompareCString, nsnull);
-}
-
-#ifdef MOZILLA_INTERNAL_API
-void nsCStringArray::SortIgnoreCase(void)
-{
-  Sort(CompareCStringIgnoreCase, nsnull);
-}
-#endif
-
-void nsCStringArray::Sort(nsCStringArrayComparatorFunc aFunc, void* aData)
-{
-  nsVoidArray::Sort(reinterpret_cast<nsVoidArrayComparatorFunc>(aFunc), aData);
-}
-
-bool 
-nsCStringArray::EnumerateForwards(nsCStringArrayEnumFunc aFunc, void* aData)
-{
-  bool    running = true;
-
-  if (mImpl)
-  {
-    PRInt32 index = -1;
-    while (running && (++index < mImpl->mCount))
-    {
-      running = (*aFunc)(*static_cast<nsCString*>(mImpl->mArray[index]), aData);
-    }
-  }
-  return running;
-}
-
-bool 
-nsCStringArray::EnumerateBackwards(nsCStringArrayEnumFunc aFunc, void* aData)
-{
-  bool    running = true;
-
-  if (mImpl)
-  {
-    PRInt32 index = Count();
-    while (running && (0 <= --index))
-    {
-      running = (*aFunc)(*static_cast<nsCString*>(mImpl->mArray[index]), aData);
-    }
-  }
-  return running;
-}
-
-
 //----------------------------------------------------------------------
 // NOTE: nsSmallVoidArray elements MUST all have the low bit as 0.
 // This means that normally it's only used for pointers, and in particular
 // structures or objects.
 nsSmallVoidArray::~nsSmallVoidArray()
 {
   if (HasSingle())
   {
--- a/xpcom/glue/nsVoidArray.h
+++ b/xpcom/glue/nsVoidArray.h
@@ -34,18 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #ifndef nsVoidArray_h___
 #define nsVoidArray_h___
 
 //#define DEBUG_VOIDARRAY 1
 
-#include "nscore.h"
-#include "nsStringGlue.h"
 #include "nsDebug.h"
 
 // Comparator callback function for sorting array values.
 typedef int (* nsVoidArrayComparatorFunc)
             (const void* aElement1, const void* aElement2, void* aData);
 
 // Enumerator callback function. Return false to stop
 typedef bool (* nsVoidArrayEnumFunc)(void* aElement, void *aData);
@@ -203,84 +201,16 @@ public:
   }
   
 protected:
   // The internal storage
   char mAutoBuf[sizeof(Impl) + (kAutoBufSize - 1) * sizeof(void*)];
 };
 
 
-class nsCString;
-
-typedef int (* nsCStringArrayComparatorFunc)
-            (const nsCString* aElement1, const nsCString* aElement2, void* aData);
-
-typedef bool (*nsCStringArrayEnumFunc)(nsCString& aElement, void *aData);
-
-class NS_COM_GLUE nsCStringArray: private nsVoidArray
-{
-public:
-  nsCStringArray(void);
-  nsCStringArray(PRInt32 aCount); // Storage for aCount elements will be pre-allocated
-  ~nsCStringArray(void);
-
-  nsCStringArray& operator=(const nsCStringArray& other);
-
-  PRInt32 Count(void) const {
-    return nsVoidArray::Count();
-  }
-
-  void CStringAt(PRInt32 aIndex, nsACString& aCString) const;
-  nsCString* CStringAt(PRInt32 aIndex) const;
-  nsCString* operator[](PRInt32 aIndex) const { return CStringAt(aIndex); }
-
-  PRInt32 IndexOf(const nsACString& aPossibleString) const;
-
-#ifdef MOZILLA_INTERNAL_API
-  PRInt32 IndexOfIgnoreCase(const nsACString& aPossibleString) const;
-#endif
-
-  bool InsertCStringAt(const nsACString& aCString, PRInt32 aIndex);
-
-  bool ReplaceCStringAt(const nsACString& aCString, PRInt32 aIndex);
-
-  bool AppendCString(const nsACString& aCString) {
-    return InsertCStringAt(aCString, Count());
-  }
-
-  bool RemoveCString(const nsACString& aCString);
-
-#ifdef MOZILLA_INTERNAL_API
-  bool RemoveCStringIgnoreCase(const nsACString& aCString);
-#endif
-
-  bool RemoveCStringAt(PRInt32 aIndex);
-  void   Clear(void);
-
-  void Compact(void) {
-    nsVoidArray::Compact();
-  }
-
-  void Sort(void);
-
-#ifdef MOZILLA_INTERNAL_API
-  void SortIgnoreCase(void);
-#endif
-
-  void Sort(nsCStringArrayComparatorFunc aFunc, void* aData);
-
-  bool EnumerateForwards(nsCStringArrayEnumFunc aFunc, void* aData);
-  bool EnumerateBackwards(nsCStringArrayEnumFunc aFunc, void* aData);
-
-private:
-  /// Copy constructors are not allowed
-  nsCStringArray(const nsCStringArray& other);
-};
-
-
 //===================================================================
 //  nsSmallVoidArray is not a general-purpose replacement for
 //  ns(Auto)VoidArray because there is (some) extra CPU overhead for arrays
 //  larger than 1 element, though not a lot.  It is appropriate for
 //  space-sensitive uses where sizes of 0 or 1 are moderately common or
 //  more, and where we're NOT storing arbitrary integers or arbitrary
 //  pointers.