Bug 485782 - get rid of nsSupportsArray; r=sicking, sr=bsmedberg
authorArpad Borsos <arpad.borsos@googlemail.com>
Tue, 14 Apr 2009 10:02:58 +0200
changeset 27300 d12b4a785ecd8fe0a11744fd5d23cbe82b0afa2d
parent 27299 3fb51dc11e1eddfb852860c0f01c79e383424781
child 27301 58d7af53721f2ac7357e769417332e39c6401780
push id6479
push userarpad.borsos@googlemail.com
push dateTue, 14 Apr 2009 08:09:02 +0000
treeherdermozilla-central@d12b4a785ecd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking, bsmedberg
bugs485782
milestone1.9.2a1pre
Bug 485782 - get rid of nsSupportsArray; r=sicking, sr=bsmedberg
content/xul/templates/src/nsXULContentBuilder.cpp
docshell/shistory/src/nsSHEntry.h
embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
js/src/xpconnect/src/xpcprivate.h
js/src/xpconnect/src/xpcwrappedjsclass.cpp
netwerk/base/src/nsIOService.h
netwerk/test/TestPageLoad.cpp
widget/src/xpwidgets/nsPrintOptionsImpl.cpp
xpcom/base/nsConsoleService.cpp
xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp
xpcom/reflect/xptinfo/src/xptiprivate.h
--- a/content/xul/templates/src/nsXULContentBuilder.cpp
+++ b/content/xul/templates/src/nsXULContentBuilder.cpp
@@ -55,17 +55,16 @@
 #include "nsTemplateRule.h"
 #include "nsTemplateMap.h"
 #include "nsTArray.h"
 #include "nsXPIDLString.h"
 #include "nsGkAtoms.h"
 #include "nsXULContentUtils.h"
 #include "nsXULElement.h"
 #include "nsXULTemplateBuilder.h"
-#include "nsSupportsArray.h"
 #include "nsNodeInfoManager.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsContentUtils.h"
 #include "nsAttrName.h"
 #include "nsNodeUtils.h"
 #include "mozAutoDocUpdate.h"
 
 #include "jsapi.h"
--- a/docshell/shistory/src/nsSHEntry.h
+++ b/docshell/shistory/src/nsSHEntry.h
@@ -51,17 +51,17 @@
 #include "nsIInputStream.h"
 #include "nsILayoutHistoryState.h"
 #include "nsISHEntry.h"
 #include "nsISHContainer.h"
 #include "nsIURI.h"
 #include "nsIEnumerator.h"
 #include "nsIHistoryEntry.h"
 #include "nsRect.h"
-#include "nsSupportsArray.h"
+#include "nsISupportsArray.h"
 #include "nsIMutationObserver.h"
 #include "nsExpirationTracker.h"
 #include "nsDocShellEditorData.h"
 
 class nsSHEntry : public nsISHEntry,
                   public nsISHContainer,
                   public nsIMutationObserver
 {
--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
+++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
@@ -1855,31 +1855,30 @@ void nsWebBrowserPersist::CleanupLocalFi
                 // children looking for files. Any files created by the
                 // persist object would have been deleted by the first
                 // pass so if there are any there at this stage, the dir
                 // cannot be deleted because it has someone else's files
                 // in it. Empty child dirs are deleted but they must be
                 // recursed through to ensure they are actually empty.
 
                 PRBool isEmptyDirectory = PR_TRUE;
-                nsSupportsArray dirStack;
-                PRUint32 stackSize = 0;
+                nsCOMArray<nsISimpleEnumerator> dirStack;
+                PRInt32 stackSize = 0;
 
                 // Push the top level enum onto the stack
                 nsCOMPtr<nsISimpleEnumerator> pos;
                 if (NS_SUCCEEDED(file->GetDirectoryEntries(getter_AddRefs(pos))))
-                    dirStack.AppendElement(pos);
-
-                while (isEmptyDirectory &&
-                    NS_SUCCEEDED(dirStack.Count(&stackSize)) && stackSize > 0)
+                    dirStack.AppendObject(pos);
+
+                while (isEmptyDirectory && (stackSize = dirStack.Count()))
                 {
                     // Pop the last element
                     nsCOMPtr<nsISimpleEnumerator> curPos;
-                    dirStack.GetElementAt(stackSize - 1, getter_AddRefs(curPos));
-                    dirStack.RemoveElementAt(stackSize - 1);
+                    curPos = dirStack[stackSize-1];
+                    dirStack.RemoveObjectAt(stackSize - 1);
                     
                     // Test if the enumerator has any more files in it
                     PRBool hasMoreElements = PR_FALSE;
                     curPos->HasMoreElements(&hasMoreElements);
                     if (!hasMoreElements)
                     {
                         continue;
                     }
@@ -1903,19 +1902,19 @@ void nsWebBrowserPersist::CleanupLocalFi
                         // Some kind of file or symlink which means dir
                         // is not empty so just drop out.
                         isEmptyDirectory = PR_FALSE;
                         break;
                     }
                     // Push parent enumerator followed by child enumerator
                     nsCOMPtr<nsISimpleEnumerator> childPos;
                     childAsFile->GetDirectoryEntries(getter_AddRefs(childPos));
-                    dirStack.AppendElement(curPos);
+                    dirStack.AppendObject(curPos);
                     if (childPos)
-                        dirStack.AppendElement(childPos);
+                        dirStack.AppendObject(childPos);
 
                 }
                 dirStack.Clear();
 
                 // If after all that walking the dir is deemed empty, delete it
                 if (isEmptyDirectory)
                 {
                     file->Remove(PR_TRUE);
--- a/js/src/xpconnect/src/xpcprivate.h
+++ b/js/src/xpconnect/src/xpcprivate.h
@@ -103,17 +103,17 @@
 
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsIExceptionService.h"
 
 #include "nsVariant.h"
 #include "nsIPropertyBag.h"
 #include "nsIProperty.h"
-#include "nsSupportsArray.h"
+#include "nsCOMArray.h"
 #include "nsTArray.h"
 #include "nsBaseHashtable.h"
 #include "nsHashKeys.h"
 #include "nsWrapperCache.h"
 
 #include "nsIXPCScriptNotify.h"  // used to notify: ScriptEvaluated
 
 #ifndef XPCONNECT_STANDALONE
@@ -2733,19 +2733,18 @@ public:
     NS_DECL_NSISIMPLEENUMERATOR
 
     xpcPropertyBagEnumerator(PRUint32 count);
     virtual ~xpcPropertyBagEnumerator() {}
 
     JSBool AppendElement(nsISupports* element);
 
 private:
-    nsSupportsArray mArray;
-    PRUint32        mIndex;
-    PRUint32        mCount;
+    nsCOMArray<nsISupports> mArray;
+    PRInt32                 mIndex;
 };
 
 /***************************************************************************/
 // data conversion
 
 // class here just for static methods
 class XPCConvert
 {
--- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp
+++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp
@@ -485,46 +485,46 @@ NS_IMETHODIMP xpcProperty::GetValue(nsIV
     return NS_OK;
 }
 
 /***************************************************************************/
 
 NS_IMPL_ISUPPORTS1(xpcPropertyBagEnumerator, nsISimpleEnumerator)
 
 xpcPropertyBagEnumerator::xpcPropertyBagEnumerator(PRUint32 count)
-    : mIndex(0), mCount(0)
+    : mIndex(0)
 {
-    mArray.SizeTo(count);
+    mArray.SetCapacity(count);
 }
 
 JSBool xpcPropertyBagEnumerator::AppendElement(nsISupports* element)
 {
-    if(!mArray.AppendElement(element))
+    if(!mArray.AppendObject(element))
         return JS_FALSE;
-    mCount++;
     return JS_TRUE;
 }
 
 /* boolean hasMoreElements (); */
 NS_IMETHODIMP xpcPropertyBagEnumerator::HasMoreElements(PRBool *_retval)
 {
-    *_retval = mIndex < mCount;
+    *_retval = mIndex < mArray.Count();
     return NS_OK;
 }
 
 /* nsISupports getNext (); */
 NS_IMETHODIMP xpcPropertyBagEnumerator::GetNext(nsISupports **_retval)
 {
-    if(!(mIndex < mCount))
+    if(!(mIndex < mArray.Count()))
     {
         NS_ERROR("Bad nsISimpleEnumerator caller!");
         return NS_ERROR_FAILURE;    
     }
     
-    *_retval = mArray.ElementAt(mIndex++);
+    *_retval = mArray.ObjectAt(mIndex++);
+    NS_IF_ADDREF(*_retval);
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
 /***************************************************************************/
 // This 'WrappedJSIdentity' class and singleton allow us to figure out if
 // any given nsISupports* is implemented by a WrappedJS object. This is done
 // using a QueryInterface call on the interface pointer with our ID. If
 // that call returns NS_OK and the pointer is to our singleton, then the
--- a/netwerk/base/src/nsIOService.h
+++ b/netwerk/base/src/nsIOService.h
@@ -45,17 +45,16 @@
 #include "nsTArray.h"
 #include "nsPISocketTransportService.h" 
 #include "nsPIDNSService.h" 
 #include "nsIProtocolProxyService2.h"
 #include "nsCOMPtr.h"
 #include "nsURLHelper.h"
 #include "nsWeakPtr.h"
 #include "nsIURLParser.h"
-#include "nsSupportsArray.h"
 #include "nsIObserver.h"
 #include "nsWeakReference.h"
 #include "nsINetUtil.h"
 #include "nsIChannelEventSink.h"
 #include "nsIContentSniffer.h"
 #include "nsCategoryCache.h"
 #include "nsINetworkLinkService.h"
 
--- a/netwerk/test/TestPageLoad.cpp
+++ b/netwerk/test/TestPageLoad.cpp
@@ -42,17 +42,17 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIProgressEventSink.h"
 #include "nsIComponentManager.h"
 #include "prprf.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "prlong.h"
 #include "plstr.h"
-#include "nsSupportsArray.h"
+#include "nsCOMArray.h"
 #include "nsIComponentRegistrar.h"
 
 namespace TestPageLoad {
 
 int getStrLine(const char *src, char *str, int ind, int max);
 nsresult auxLoad(char *uriBuf);
 //----------------------------------------------------------------------
 
@@ -63,17 +63,17 @@ nsresult auxLoad(char *uriBuf);
         printf(">>> %s failed: rv=%x\n", step, rv); \
         return rv;\
     } \
     PR_END_MACRO
 
 static nsCString globalStream;
 //static char urlBuf[256];
 static nsCOMPtr<nsIURI> baseURI;
-static nsCOMPtr<nsISupportsArray> uriList;
+static nsCOMArray<nsIURI> uriList;
 
 //Temp, should remove:
 static int numStart=0;
 static int numFound=0;
 
 static PRInt32 gKeepRunning = 0;
 
 
@@ -312,30 +312,26 @@ nsresult auxLoad(char *uriBuf)
       if (NS_FAILED(rv)) return(rv);
     } else {
       //Absolute link, no base needed
       rv = NS_NewURI(getter_AddRefs(uri), uriBuf);
       if (NS_FAILED(rv)) return(rv);
     }
 
     //Compare to see if exists
-    PRUint32 num;
-    uriList->Count(&num);
     PRBool equal;
-    nsCOMPtr<nsIURI> uriTmp;
-    for(PRUint32 i = 0; i < num; i++) {
-      uriList->GetElementAt(i, getter_AddRefs(uriTmp));
-      uri->Equals(uriTmp, &equal);
+    for(PRInt32 i = 0; i < uriList.Count(); i++) {
+      uri->Equals(uriList[i], &equal);
       if(equal) {
         printf("(duplicate, canceling) %s\n",uriBuf); 
         return NS_OK;
       }
     }
     printf("\n");
-    uriList->AppendElement(uri);
+    uriList.AppendObject(uri);
     rv = NS_NewChannel(getter_AddRefs(chan), uri, nsnull, nsnull, callbacks);
     RETURN_IF_FAILED(rv, "NS_NewChannel");
 
     gKeepRunning++;
     rv = chan->AsyncOpen(listener, myBool);
     RETURN_IF_FAILED(rv, "AsyncOpen");
 
     return NS_OK;
@@ -366,19 +362,16 @@ int main(int argc, char **argv)
         NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
         nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
         NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
         if (registrar)
             registrar->AutoRegister(nsnull);
 
         PRTime start, finish;
 
-        uriList = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
-        RETURN_IF_FAILED(rv, "do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID)");
-
         printf("Loading necko ... \n");
         nsCOMPtr<nsIChannel> chan;
         nsCOMPtr<nsIStreamListener> listener = new MyListener();
         nsCOMPtr<nsIInterfaceRequestor> callbacks = new MyNotifications();
 
         rv = NS_NewURI(getter_AddRefs(baseURI), argv[1]);
         RETURN_IF_FAILED(rv, "NS_NewURI");
 
--- a/widget/src/xpwidgets/nsPrintOptionsImpl.cpp
+++ b/widget/src/xpwidgets/nsPrintOptionsImpl.cpp
@@ -43,17 +43,17 @@
 
 #include "nsIDOMWindow.h"
 #include "nsIServiceManager.h"
 #include "nsIDialogParamBlock.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIWindowWatcher.h"
 #include "nsIDOMWindowInternal.h"
-#include "nsSupportsArray.h"
+#include "nsISupportsArray.h"
 #include "prprf.h"
 
 // For Prefs
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsIServiceManager.h"
 
 #include "nsIStringEnumerator.h"
--- a/xpcom/base/nsConsoleService.cpp
+++ b/xpcom/base/nsConsoleService.cpp
@@ -41,17 +41,17 @@
  * listeners when new messages are logged.
  */
 
 /* Threadsafe. */
 
 #include "nsMemory.h"
 #include "nsIServiceManager.h"
 #include "nsIProxyObjectManager.h"
-#include "nsSupportsArray.h"
+#include "nsCOMArray.h"
 #include "nsThreadUtils.h"
 
 #include "nsConsoleService.h"
 #include "nsConsoleMessage.h"
 #include "nsIClassInfoImpl.h"
 
 NS_IMPL_THREADSAFE_ADDREF(nsConsoleService)
 NS_IMPL_THREADSAFE_RELEASE(nsConsoleService)
@@ -106,31 +106,32 @@ nsConsoleService::Init()
     if (!mLock)
         return NS_ERROR_OUT_OF_MEMORY;
 
     return NS_OK;
 }
 
 static PRBool snapshot_enum_func(nsHashKey *key, void *data, void* closure)
 {
-    nsISupportsArray *array = (nsISupportsArray *)closure;
+    nsCOMArray<nsIConsoleListener> *array =
+      reinterpret_cast<nsCOMArray<nsIConsoleListener> *>(closure);
 
-    // Copy each element into the temporary nsSupportsArray...
-    array->AppendElement((nsISupports*)data);
+    // Copy each element into the temporary nsCOMArray...
+    array->AppendObject((nsIConsoleListener*)data);
     return PR_TRUE;
 }
 
 // nsIConsoleService methods
 NS_IMETHODIMP
 nsConsoleService::LogMessage(nsIConsoleMessage *message)
 {
     if (message == nsnull)
         return NS_ERROR_INVALID_ARG;
 
-    nsSupportsArray listenersSnapshot;
+    nsCOMArray<nsIConsoleListener> listenersSnapshot;
     nsIConsoleMessage *retiredMessage;
 
     NS_ADDREF(message); // early, in case it's same as replaced below.
 
     /*
      * Lock while updating buffer, and while taking snapshot of
      * listeners array.
      */
@@ -162,46 +163,35 @@ nsConsoleService::LogMessage(nsIConsoleM
     /*
      * Iterate through any registered listeners and tell them about
      * the message.  We use the mListening flag to guard against
      * recursive message logs.  This could sometimes result in
      * listeners being skipped because of activity on other threads,
      * when we only care about the recursive case.
      */
     nsCOMPtr<nsIConsoleListener> listener;
-    nsresult rv;
-    nsresult returned_rv;
-    PRUint32 snapshotCount;
-    rv = listenersSnapshot.Count(&snapshotCount);
-    if (NS_FAILED(rv))
-        return rv;
+    PRInt32 snapshotCount = listenersSnapshot.Count();
 
     {
         nsAutoLock lock(mLock);
         if (mListening)
             return NS_OK;
         mListening = PR_TRUE;
     }
 
-    returned_rv = NS_OK;
-    for (PRUint32 i = 0; i < snapshotCount; i++) {
-        rv = listenersSnapshot.GetElementAt(i, getter_AddRefs(listener));
-        if (NS_FAILED(rv)) {
-            returned_rv = rv;
-            break; // fall thru to mListening restore code below.
-        }
-        listener->Observe(message);
+    for (PRInt32 i = 0; i < snapshotCount; i++) {
+        listenersSnapshot[i]->Observe(message);
     }
     
     {
         nsAutoLock lock(mLock);
         mListening = PR_FALSE;
     }
 
-    return returned_rv;
+    return NS_OK;
 }
 
 NS_IMETHODIMP
 nsConsoleService::LogStringMessage(const PRUnichar *message)
 {
     nsConsoleMessage *msg = new nsConsoleMessage(message);
     return this->LogMessage(msg);
 }
--- a/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp
+++ b/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp
@@ -1968,145 +1968,135 @@ NS_IMETHODIMP xptiInterfaceInfoManager::
 class xptiAdditionalManagersEnumerator : public nsISimpleEnumerator 
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSISIMPLEENUMERATOR
 
     xptiAdditionalManagersEnumerator();
 
-    PRBool SizeTo(PRUint32 likelyCount) {return mArray.SizeTo(likelyCount);}
+    PRBool SizeTo(PRUint32 likelyCount) {return mArray.SetCapacity(likelyCount);}
     PRBool AppendElement(nsIInterfaceInfoManager* element);
 
 private:
     ~xptiAdditionalManagersEnumerator() {}
 
-    nsSupportsArray mArray;
-    PRUint32        mIndex;
-    PRUint32        mCount;
+    nsCOMArray<nsISupports> mArray;
+    PRInt32                 mIndex;
 };
 
 NS_IMPL_ISUPPORTS1(xptiAdditionalManagersEnumerator, nsISimpleEnumerator)
 
 xptiAdditionalManagersEnumerator::xptiAdditionalManagersEnumerator()
-    : mIndex(0), mCount(0)
+    : mIndex(0)
 {
 }
 
 PRBool xptiAdditionalManagersEnumerator::AppendElement(nsIInterfaceInfoManager* element)
 {
-    if(!mArray.AppendElement(static_cast<nsISupports*>(element)))
+    if(!mArray.AppendObject(element))
         return PR_FALSE;
-    mCount++;
     return PR_TRUE;
 }
 
 /* boolean hasMoreElements (); */
 NS_IMETHODIMP xptiAdditionalManagersEnumerator::HasMoreElements(PRBool *_retval)
 {
-    *_retval = mIndex < mCount;
+    *_retval = mIndex < mArray.Count();
     return NS_OK;
 }
 
 /* nsISupports getNext (); */
 NS_IMETHODIMP xptiAdditionalManagersEnumerator::GetNext(nsISupports **_retval)
 {
-    if(!(mIndex < mCount))
+    if(!(mIndex < mArray.Count()))
     {
         NS_ERROR("Bad nsISimpleEnumerator caller!");
         return NS_ERROR_FAILURE;    
     }
 
-    *_retval = mArray.ElementAt(mIndex++);
+    *_retval = mArray.ObjectAt(mIndex++);
+    NS_IF_ADDREF(*_retval);
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
 /***************************************************************************/
 
 /* void addAdditionalManager (in nsIInterfaceInfoManager manager); */
 NS_IMETHODIMP xptiInterfaceInfoManager::AddAdditionalManager(nsIInterfaceInfoManager *manager)
 {
     nsCOMPtr<nsIWeakReference> weakRef = do_GetWeakReference(manager);
     nsISupports* ptrToAdd = weakRef ? 
                     static_cast<nsISupports*>(weakRef) :
                     static_cast<nsISupports*>(manager);
     { // scoped lock...
         nsAutoLock lock(mAdditionalManagersLock);
-        PRInt32 index;
-        nsresult rv = mAdditionalManagers.GetIndexOf(ptrToAdd, &index);
-        if(NS_FAILED(rv) || -1 != index)
+        if(mAdditionalManagers.IndexOf(ptrToAdd) != -1)
             return NS_ERROR_FAILURE;
-        if(!mAdditionalManagers.AppendElement(ptrToAdd))
+        if(!mAdditionalManagers.AppendObject(ptrToAdd))
             return NS_ERROR_OUT_OF_MEMORY;
     }
     return NS_OK;
 }
 
 /* void removeAdditionalManager (in nsIInterfaceInfoManager manager); */
 NS_IMETHODIMP xptiInterfaceInfoManager::RemoveAdditionalManager(nsIInterfaceInfoManager *manager)
 {
     nsCOMPtr<nsIWeakReference> weakRef = do_GetWeakReference(manager);
     nsISupports* ptrToRemove = weakRef ? 
                     static_cast<nsISupports*>(weakRef) :
                     static_cast<nsISupports*>(manager);
     { // scoped lock...
         nsAutoLock lock(mAdditionalManagersLock);
-        if(!mAdditionalManagers.RemoveElement(ptrToRemove))
+        if(!mAdditionalManagers.RemoveObject(ptrToRemove))
             return NS_ERROR_FAILURE;
     }
     return NS_OK;
 }
 
 /* PRBool hasAdditionalManagers (); */
 NS_IMETHODIMP xptiInterfaceInfoManager::HasAdditionalManagers(PRBool *_retval)
 {
-    PRUint32 count;
-    nsresult rv = mAdditionalManagers.Count(&count);
-    *_retval = count != 0;
-    return rv;
+    *_retval = mAdditionalManagers.Count() > 0;
+    return NS_OK;
 }
 
 /* nsISimpleEnumerator enumerateAdditionalManagers (); */
 NS_IMETHODIMP xptiInterfaceInfoManager::EnumerateAdditionalManagers(nsISimpleEnumerator **_retval)
 {
     nsAutoLock lock(mAdditionalManagersLock);
 
-    PRUint32 count;
-    nsresult rv = mAdditionalManagers.Count(&count);
-    if(NS_FAILED(rv))
-        return rv;
+    PRInt32 count = mAdditionalManagers.Count();
 
     nsCOMPtr<xptiAdditionalManagersEnumerator> enumerator = 
         new xptiAdditionalManagersEnumerator();
     if(!enumerator)
         return NS_ERROR_OUT_OF_MEMORY;
 
     enumerator->SizeTo(count);
 
-    for(PRUint32 i = 0; i < count; /* i incremented in the loop body */)
+    for(PRInt32 i = 0; i < count; /* i incremented in the loop body */)
     {
-        nsCOMPtr<nsISupports> raw = 
-            dont_AddRef(mAdditionalManagers.ElementAt(i++));
+        nsCOMPtr<nsISupports> raw = mAdditionalManagers.ObjectAt(i++);
         if(!raw)
             return NS_ERROR_FAILURE;
         nsCOMPtr<nsIWeakReference> weakRef = do_QueryInterface(raw);
         if(weakRef)
         {
             nsCOMPtr<nsIInterfaceInfoManager> manager = 
                 do_QueryReferent(weakRef);
             if(manager)
             {
                 if(!enumerator->AppendElement(manager))
                     return NS_ERROR_FAILURE;
             }
             else
             {
                 // The manager is no more. Remove the element.
-                if(!mAdditionalManagers.RemoveElementAt(--i))
-                    return NS_ERROR_FAILURE;
+                mAdditionalManagers.RemoveObjectAt(--i);
                 count--;
             }
         }
         else
         {
             // We *know* we put a pointer to either a nsIWeakReference or
             // an nsIInterfaceInfoManager into the array, so we can avoid an
             // extra QI here and just do a cast.
--- a/xpcom/reflect/xptinfo/src/xptiprivate.h
+++ b/xpcom/reflect/xptinfo/src/xptiprivate.h
@@ -61,19 +61,18 @@
 #include "nsDirectoryServiceDefs.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsIWeakReference.h"
 
 #include "nsCRT.h"
 #include "nsMemory.h"
 
 #include "nsISupportsArray.h"
-#include "nsSupportsArray.h"
+#include "nsCOMArray.h"
 #include "nsInt64.h"
-
 #include "nsQuickSort.h"
 
 #include "nsXPIDLString.h"
 
 #include "nsIInputStream.h"
 
 #include "nsAutoLock.h"
 
@@ -963,17 +962,17 @@ private:
     xptiWorkingSet               mWorkingSet;
     nsCOMPtr<nsILocalFile>       mStatsLogFile;
     nsCOMPtr<nsILocalFile>       mAutoRegLogFile;
     PRFileDesc*                  mOpenLogFile;
     PRLock*                      mResolveLock;
     PRLock*                      mAutoRegLock;
     PRMonitor*                   mInfoMonitor;
     PRLock*                      mAdditionalManagersLock;
-    nsSupportsArray              mAdditionalManagers;
+    nsCOMArray<nsISupports>      mAdditionalManagers;
     nsCOMPtr<nsISupportsArray>   mSearchPath;
 };
 
 /***************************************************************************/
 // utilities...
 
 nsresult xptiCloneLocalFile(nsILocalFile*  aLocalFile,
                             nsILocalFile** aCloneLocalFile);