nsObserverTopic has a few efficiency issues:
1. GetTopic() is a linear search of topics. Perhaps it should be a hashtable of
2. Notify() takes all the keys and values (which are strings), and then adds
them to nsVoidArrays along with a few extra items. This causes quite a few
allocations (both of strings and nsVoidArray structures), and the Observers
shouldn't be modifying the keys/values anyways. Perhaps these should be passed
by reference. (The strings may not duplicate all the storage due to how our
string classes work; here's the code:
nsString* string = new nsString(aString);
if (nsVoidArray::InsertElementAt(string, aIndex))
I dealt with the allocations of VoidArray in bug 90545. The issues of
allocations of strings still applies.
With fix for bug 96364 GetTopic() ( rather GetEntry() )should not be an issue
since the number of calls to GetEntry() has reduced a LOT.
Lowering the priority based on my previous comment.
Out of time :-( Moving to 0.9.7
Randell: Is this still an issue?
Yes, I believe so. Check dbaron's pageload jprof to get an idea if it's important.
Out of time. Mass move to 0.9.9
Mass moving to 1.1.
Case 1 is now a hashtable as suggested, and case 2 no longer does the code snippet shown; it inserts fairly directly into an nsCOMArray in nsObserverList, so this is fixed.