mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 04:09:50 +00:00
Bug 1359848 - Part 2: Avoid two hashtable lookups when registering a new preference observer; r=froydnj
This commit is contained in:
parent
49ea4e277a
commit
7f9af03e0b
@ -723,13 +723,14 @@ NS_IMETHODIMP nsPrefBranch::AddObserver(const char *aDomain, nsIObserver *aObser
|
||||
pCallback = new PrefCallback(aDomain, aObserver, this);
|
||||
}
|
||||
|
||||
if (mObservers.Get(pCallback)) {
|
||||
auto p = mObservers.LookupForAdd(pCallback);
|
||||
if (p) {
|
||||
NS_WARNING("Ignoring duplicate observer.");
|
||||
delete pCallback;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mObservers.Put(pCallback, pCallback);
|
||||
mObservers.Insert(p, pCallback);
|
||||
|
||||
// We must pass a fully qualified preference name to the callback
|
||||
// aDomain == nullptr is the only possible failure, and we trapped it with
|
||||
|
Loading…
x
Reference in New Issue
Block a user