While looking at tbsaunde's patch to remove the nsISupportsArray version of NS_NewArrayEnumerator I noticed that many users of NS_NewArrayEnumerator copy entries from a hash into a temporary array which they then enumerate, which works by creating an instance of an enumerator class that recopies the entries from the temporary array. Would it make sense to create an array enumerator class that was preallocated to a given capacity and then filled directly? The API would look like this (error checking omitted for clarity):

nsCOMEnumerator* result = NS_NewCOMEnumerator(mHash.entryCount);
HashTableEnumerate(mHash, AppendElementToEnumerator, result);
aResult = result;

--
Warning: May contain traces of nuts.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to