diff --git a/xpcom/glue/nsVoidArray.cpp b/xpcom/glue/nsVoidArray.cpp index acf8b38e4a26..8ebc665c9733 100644 --- a/xpcom/glue/nsVoidArray.cpp +++ b/xpcom/glue/nsVoidArray.cpp @@ -384,11 +384,11 @@ nsStringArray::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const } void -nsStringArray::StringAt(PRInt32 aIndex, nsString& aString) const +nsStringArray::StringAt(PRInt32 aIndex, nsAWritableString& aString) const { nsString* string = NS_STATIC_CAST(nsString*, nsVoidArray::ElementAt(aIndex)); if (nsnull != string) { - aString = *string; + aString.Assign(*string); } else { aString.Truncate(); @@ -402,7 +402,7 @@ nsStringArray::StringAt(PRInt32 aIndex) const } PRInt32 -nsStringArray::IndexOf(const nsString& aPossibleString) const +nsStringArray::IndexOf(const nsAReadableString& aPossibleString) const { if (mImpl) { void** ap = mImpl->mArray; @@ -419,14 +419,19 @@ nsStringArray::IndexOf(const nsString& aPossibleString) const } PRInt32 -nsStringArray::IndexOfIgnoreCase(const nsString& aPossibleString) const +nsStringArray::IndexOfIgnoreCase(const nsAReadableString& aPossibleString) const { + // XXX + // nsString::EqualsIgnoreCase() doesn't take a nsAReadableString& so we + // construct a stack based string here and do a copy... + nsAutoString possible_string(aPossibleString); + if (mImpl) { void** ap = mImpl->mArray; void** end = ap + mImpl->mCount; while (ap < end) { nsString* string = NS_STATIC_CAST(nsString*, *ap); - if (string->EqualsIgnoreCase(aPossibleString)) { + if (string->EqualsIgnoreCase(possible_string)) { return ap - mImpl->mArray; } ap++; @@ -436,7 +441,7 @@ nsStringArray::IndexOfIgnoreCase(const nsString& aPossibleString) const } PRBool -nsStringArray::InsertStringAt(const nsString& aString, PRInt32 aIndex) +nsStringArray::InsertStringAt(const nsAReadableString& aString, PRInt32 aIndex) { nsString* string = new nsString(aString); if (nsVoidArray::InsertElementAt(string, aIndex)) { @@ -447,7 +452,8 @@ nsStringArray::InsertStringAt(const nsString& aString, PRInt32 aIndex) } PRBool -nsStringArray::ReplaceStringAt(const nsString& aString, PRInt32 aIndex) +nsStringArray::ReplaceStringAt(const nsAReadableString& aString, + PRInt32 aIndex) { nsString* string = NS_STATIC_CAST(nsString*, nsVoidArray::ElementAt(aIndex)); if (nsnull != string) { @@ -458,7 +464,7 @@ nsStringArray::ReplaceStringAt(const nsString& aString, PRInt32 aIndex) } PRBool -nsStringArray::RemoveString(const nsString& aString) +nsStringArray::RemoveString(const nsAReadableString& aString) { PRInt32 index = IndexOf(aString); if (-1 < index) { @@ -468,7 +474,7 @@ nsStringArray::RemoveString(const nsString& aString) } PRBool -nsStringArray::RemoveStringIgnoreCase(const nsString& aString) +nsStringArray::RemoveStringIgnoreCase(const nsAReadableString& aString) { PRInt32 index = IndexOfIgnoreCase(aString); if (-1 < index) { diff --git a/xpcom/glue/nsVoidArray.h b/xpcom/glue/nsVoidArray.h index 3435e04d81af..3f1a05018671 100644 --- a/xpcom/glue/nsVoidArray.h +++ b/xpcom/glue/nsVoidArray.h @@ -24,6 +24,7 @@ #define nsVoidArray_h___ #include "nscore.h" +#include "nsAWritableString.h" class nsISizeOfHandler; // Enumerator callback function. Return PR_FALSE to stop @@ -138,23 +139,23 @@ public: return nsVoidArray::Count(); } - void StringAt(PRInt32 aIndex, nsString& aString) const; + void StringAt(PRInt32 aIndex, nsAWritableString& aString) const; nsString* StringAt(PRInt32 aIndex) const; nsString* operator[](PRInt32 aIndex) const { return StringAt(aIndex); } - PRInt32 IndexOf(const nsString& aPossibleString) const; - PRInt32 IndexOfIgnoreCase(const nsString& aPossibleString) const; + PRInt32 IndexOf(const nsAReadableString& aPossibleString) const; + PRInt32 IndexOfIgnoreCase(const nsAReadableString& aPossibleString) const; - PRBool InsertStringAt(const nsString& aString, PRInt32 aIndex); + PRBool InsertStringAt(const nsAReadableString& aString, PRInt32 aIndex); - PRBool ReplaceStringAt(const nsString& aString, PRInt32 aIndex); + PRBool ReplaceStringAt(const nsAReadableString& aString, PRInt32 aIndex); - PRBool AppendString(const nsString& aString) { + PRBool AppendString(const nsAReadableString& aString) { return InsertStringAt(aString, Count()); } - PRBool RemoveString(const nsString& aString); - PRBool RemoveStringIgnoreCase(const nsString& aString); + PRBool RemoveString(const nsAReadableString& aString); + PRBool RemoveStringIgnoreCase(const nsAReadableString& aString); PRBool RemoveStringAt(PRInt32 aIndex); void Clear(void);