This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.11.0esr-11.5-1 in repository tor-browser.
commit 86f3114eae37be0c904d8b6ffe4d5a9b0b261eb2 Author: Gijs Kruitbosch gijskruitbosch@gmail.com AuthorDate: Wed May 25 17:02:00 2022 +0000
Bug 1770848, r=jaws,mccr8 a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D147116 --- .../contentprefs/ContentPrefService2.jsm | 53 ++++++++++------------ 1 file changed, 25 insertions(+), 28 deletions(-)
diff --git a/toolkit/components/contentprefs/ContentPrefService2.jsm b/toolkit/components/contentprefs/ContentPrefService2.jsm index 1c3536bd80d43..49206f6680f32 100644 --- a/toolkit/components/contentprefs/ContentPrefService2.jsm +++ b/toolkit/components/contentprefs/ContentPrefService2.jsm @@ -114,7 +114,7 @@ ContentPrefService2.prototype = {
// Destruction
- _destroy: function CPS2__destroy() { + _destroy() { Services.obs.removeObserver(this, "profile-before-change"); Services.obs.removeObserver(this, "last-pb-context-exited");
@@ -972,41 +972,38 @@ ContentPrefService2.prototype = { },
// A hash of arrays of observers, indexed by setting name. - _observers: {}, + _observers: new Map(),
// An array of generic observers, which observe all settings. - _genericObservers: [], + _genericObservers: new Set(),
- addObserverForName: function CPS2_addObserverForName(aName, aObserver) { - var observers; + addObserverForName(aName, aObserver) { + let observers; if (aName) { - if (!this._observers[aName]) { - this._observers[aName] = []; + observers = this._observers.get(aName); + if (!observers) { + observers = new Set(); + this._observers.set(aName, observers); } - observers = this._observers[aName]; } else { observers = this._genericObservers; }
- if (!observers.includes(aObserver)) { - observers.push(aObserver); - } + observers.add(aObserver); },
- removeObserverForName: function CPS2_removeObserverForName(aName, aObserver) { - var observers; + removeObserverForName(aName, aObserver) { + let observers; if (aName) { - if (!this._observers[aName]) { + observers = this._observers.get(aName); + if (!observers) { return; } - observers = this._observers[aName]; } else { observers = this._genericObservers; }
- if (observers.includes(aObserver)) { - observers.splice(observers.indexOf(aObserver), 1); - } + observers.delete(aObserver); },
/** @@ -1016,15 +1013,15 @@ ContentPrefService2.prototype = { * execute before observers that display multiple settings and depend on them * being initialized first (like the content prefs sidebar). */ - _getObservers: function ContentPrefService__getObservers(aName) { - var observers = []; - - if (aName && this._observers[aName]) { - observers = observers.concat(this._observers[aName]); + _getObservers(aName) { + let genericObserverList = Array.from(this._genericObservers); + if (aName) { + let observersForName = this._observers.get(aName); + if (observersForName) { + return Array.from(observersForName).concat(genericObserverList); + } } - observers = observers.concat(this._genericObservers); - - return observers; + return genericObserverList; },
/** @@ -1101,8 +1098,8 @@ ContentPrefService2.prototype = { this._pbStore.removeAll(); this._cache.removeAll();
- this._observers = {}; - this._genericObservers = []; + this._observers = new Map(); + this._genericObservers = new Set();
let tables = ["prefs", "groups", "settings"]; let stmts = tables.map(t => this._stmt(`DELETE FROM ${t}`));