Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: messageResponder.js

Issue 29339088: Noissue - Use hash tables instead arrays to keep track of registered listeners (Closed)
Patch Set: Created March 29, 2016, 9:46 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: messageResponder.js
===================================================================
--- a/messageResponder.js
+++ b/messageResponder.js
@@ -69,8 +69,8 @@
var convertFilter = convertObject.bind(null, ["text"]);
var changeListeners = new global.ext.PageMap();
- var listenedPreferences = [];
- var listenedFilterChanges = [];
+ var listenedPreferences = Object.create(null);
+ var listenedFilterChanges = Object.create(null);
var messageTypes = {
"app": "app.listen",
"filter": "filters.listen",
@@ -122,9 +122,9 @@
else
name = type + "." + action;
- if (listenedFilterChanges.indexOf(name) == -1)
+ if (!(name in listenedFilterChanges))
{
- listenedFilterChanges.push(name);
+ listenedFilterChanges[name] = null;
FilterNotifier.on(name, function()
{
var args = [type, action];
@@ -310,9 +310,9 @@
getListenerFilters(sender.page).pref = message.filter;
message.filter.forEach(function(preference)
{
- if (listenedPreferences.indexOf(preference) == -1)
+ if (!(preference in listenedPreferences))
{
- listenedPreferences.push(preference);
+ listenedPreferences[preference] = null;
Prefs.on(preference, function()
{
sendMessage("pref", preference, Prefs[preference]);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld