On 12/18/2012 11:05 AM, Neil wrote:
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;
Is this specific to maps becoming enumerators, and could we just make
that API specifically? I don't mind this API. You could also just have
an enumerator which adopts a nsCOMArray_base or a nsTArray.
--BDS
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform