Bug 642408 - Drop nsStringArray now that it is no longer used, r=bsmedberg
authorMark Banner <bugzilla@standard8.plus.com>
Wed, 23 Mar 2011 15:13:41 -0400
changeset 63560 bbe7d1e967ef7b9b3c3760845cddc6a9821060c4
parent 63559 e92ddaea90ae2985b63483360f1e9a07f7cabed9
child 63561 048b078d112dbf6a76e3cd37e61023cae58c5282
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs642408
milestone2.2a1pre
Bug 642408 - Drop nsStringArray now that it is no longer used, r=bsmedberg
xpcom/glue/nsVoidArray.cpp
xpcom/glue/nsVoidArray.h
--- a/xpcom/glue/nsVoidArray.cpp
+++ b/xpcom/glue/nsVoidArray.cpp
@@ -753,234 +753,16 @@ nsAutoVoidArray::nsAutoVoidArray()
 #if DEBUG_VOIDARRAY
   mIsAuto = PR_TRUE;
   ADD_TO_STATS(MaxAuto,0);
 #endif
   ResetToAutoBuffer();
 }
 
 //----------------------------------------------------------------
-// nsStringArray
-
-nsStringArray::nsStringArray(void)
-  : nsVoidArray()
-{
-}
-
-nsStringArray::nsStringArray(PRInt32 aCount)
-  : nsVoidArray(aCount)
-{
-}
-
-nsStringArray::~nsStringArray(void)
-{
-  Clear();
-}
-
-nsStringArray& 
-nsStringArray::operator=(const nsStringArray& 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)
-  {
-    nsString* oldString = static_cast<nsString*>(other.ElementAt(i));
-    nsString* newString = new nsString(*oldString);
-    if (!newString)
-    {
-      mImpl->mCount = i;
-      return *this;
-    }
-    mImpl->mArray[i] = newString;
-  }
-
-  return *this;
-}
-
-void 
-nsStringArray::StringAt(PRInt32 aIndex, nsAString& aString) const
-{
-  nsString* string = static_cast<nsString*>(nsVoidArray::ElementAt(aIndex));
-  if (nsnull != string)
-  {
-    aString.Assign(*string);
-  }
-  else
-  {
-    aString.Truncate();
-  }
-}
-
-nsString*
-nsStringArray::StringAt(PRInt32 aIndex) const
-{
-  return static_cast<nsString*>(nsVoidArray::ElementAt(aIndex));
-}
-
-PRInt32 
-nsStringArray::IndexOf(const nsAString& aPossibleString) const
-{
-  if (mImpl)
-  {
-    void** ap = mImpl->mArray;
-    void** end = ap + mImpl->mCount;
-    while (ap < end)
-    {
-      nsString* string = static_cast<nsString*>(*ap);
-      if (string->Equals(aPossibleString))
-      {
-        return ap - mImpl->mArray;
-      }
-      ap++;
-    }
-  }
-  return -1;
-}
-
-PRBool 
-nsStringArray::InsertStringAt(const nsAString& aString, PRInt32 aIndex)
-{
-  nsString* string = new nsString(aString);
-  if (!string)
-    return PR_FALSE;
-  if (nsVoidArray::InsertElementAt(string, aIndex))
-    return PR_TRUE;
-
-  delete string;
-  return PR_FALSE;
-}
-
-PRBool
-nsStringArray::ReplaceStringAt(const nsAString& aString,
-                               PRInt32 aIndex)
-{
-  nsString* string = static_cast<nsString*>(nsVoidArray::ElementAt(aIndex));
-  if (nsnull != string)
-  {
-    *string = aString;
-    return PR_TRUE;
-  }
-  return PR_FALSE;
-}
-
-PRBool 
-nsStringArray::RemoveString(const nsAString& aString)
-{
-  PRInt32 index = IndexOf(aString);
-  if (-1 < index)
-  {
-    return RemoveStringAt(index);
-  }
-  return PR_FALSE;
-}
-
-PRBool nsStringArray::RemoveStringAt(PRInt32 aIndex)
-{
-  nsString* string = StringAt(aIndex);
-  if (nsnull != string)
-  {
-    nsVoidArray::RemoveElementAt(aIndex);
-    delete string;
-    return PR_TRUE;
-  }
-  return PR_FALSE;
-}
-
-void 
-nsStringArray::Clear(void)
-{
-  PRInt32 index = Count();
-  while (0 <= --index)
-  {
-    nsString* string = static_cast<nsString*>(mImpl->mArray[index]);
-    delete string;
-  }
-  nsVoidArray::Clear();
-}
-
-static int
-CompareString(const nsString* aString1, const nsString* aString2, void*)
-{
-#ifdef MOZILLA_INTERNAL_API
-  return Compare(*aString1, *aString2);
-#else
-  const PRUnichar* s1;
-  const PRUnichar* s2;
-  PRUint32 len1 = NS_StringGetData(*aString1, &s1);
-  PRUint32 len2 = NS_StringGetData(*aString2, &s2);
-  int r = memcmp(s1, s2, sizeof(PRUnichar) * PR_MIN(len1, len2));
-  if (r)
-    return r;
-
-  if (len1 < len2)
-    return -1;
-
-  if (len1 > len2)
-    return 1;
-
-  return 0;
-#endif
-}
-
-void nsStringArray::Sort(void)
-{
-  Sort(CompareString, nsnull);
-}
-
-void nsStringArray::Sort(nsStringArrayComparatorFunc aFunc, void* aData)
-{
-  nsVoidArray::Sort(reinterpret_cast<nsVoidArrayComparatorFunc>(aFunc), aData);
-}
-
-PRBool 
-nsStringArray::EnumerateForwards(nsStringArrayEnumFunc aFunc, void* aData)
-{
-  PRInt32 index = -1;
-  PRBool  running = PR_TRUE;
-
-  if (mImpl)
-  {
-    while (running && (++index < mImpl->mCount))
-    {
-      running = (*aFunc)(*static_cast<nsString*>(mImpl->mArray[index]), aData);
-    }
-  }
-  return running;
-}
-
-PRBool 
-nsStringArray::EnumerateBackwards(nsStringArrayEnumFunc aFunc, void* aData)
-{
-  PRInt32 index = Count();
-  PRBool  running = PR_TRUE;
-
-  if (mImpl)
-  {
-    while (running && (0 <= --index))
-    {
-      running = (*aFunc)(*static_cast<nsString*>(mImpl->mArray[index]), aData);
-    }
-  }
-  return running;
-}
-
-
-
-//----------------------------------------------------------------
 // nsCStringArray
 
 nsCStringArray::nsCStringArray(void)
   : nsVoidArray()
 {
 }
 
 nsCStringArray::nsCStringArray(PRInt32 aCount)
--- a/xpcom/glue/nsVoidArray.h
+++ b/xpcom/glue/nsVoidArray.h
@@ -203,70 +203,16 @@ public:
   }
   
 protected:
   // The internal storage
   char mAutoBuf[sizeof(Impl) + (kAutoBufSize - 1) * sizeof(void*)];
 };
 
 
-class nsString;
-
-typedef int (* nsStringArrayComparatorFunc)
-            (const nsString* aElement1, const nsString* aElement2, void* aData);
-
-typedef PRBool (*nsStringArrayEnumFunc)(nsString& aElement, void *aData);
-
-class NS_COM_GLUE nsStringArray: private nsVoidArray
-{
-public:
-  nsStringArray(void);
-  nsStringArray(PRInt32 aCount);  // Storage for aCount elements will be pre-allocated
-  ~nsStringArray(void);
-
-  nsStringArray& operator=(const nsStringArray& other);
-
-  PRInt32 Count(void) const {
-    return nsVoidArray::Count();
-  }
-
-  void StringAt(PRInt32 aIndex, nsAString& aString) const;
-  nsString* StringAt(PRInt32 aIndex) const;
-  nsString* operator[](PRInt32 aIndex) const { return StringAt(aIndex); }
-
-  PRInt32 IndexOf(const nsAString& aPossibleString) const;
-
-  PRBool InsertStringAt(const nsAString& aString, PRInt32 aIndex);
-
-  PRBool ReplaceStringAt(const nsAString& aString, PRInt32 aIndex);
-
-  PRBool AppendString(const nsAString& aString) {
-    return InsertStringAt(aString, Count());
-  }
-
-  PRBool RemoveString(const nsAString& aString);
-  PRBool RemoveStringAt(PRInt32 aIndex);
-  void   Clear(void);
-
-  void Compact(void) {
-    nsVoidArray::Compact();
-  }
-
-  void Sort(void);
-  void Sort(nsStringArrayComparatorFunc aFunc, void* aData);
-
-  PRBool EnumerateForwards(nsStringArrayEnumFunc aFunc, void* aData);
-  PRBool EnumerateBackwards(nsStringArrayEnumFunc aFunc, void* aData);
-
-private:
-  /// Copy constructors are not allowed
-  nsStringArray(const nsStringArray& other);
-};
-
-
 class nsCString;
 
 typedef int (* nsCStringArrayComparatorFunc)
             (const nsCString* aElement1, const nsCString* aElement2, void* aData);
 
 typedef PRBool (*nsCStringArrayEnumFunc)(nsCString& aElement, void *aData);
 
 class NS_COM_GLUE nsCStringArray: private nsVoidArray