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

Side by Side Diff: ext/common.js

Issue 29418653: Noissue - Do not make a copy of _listeners while dispatching (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created April 20, 2017, 5:43 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 19 matching lines...) Expand all
30 { 30 {
31 this._listeners.add(listener); 31 this._listeners.add(listener);
32 }, 32 },
33 removeListener(listener) 33 removeListener(listener)
34 { 34 {
35 this._listeners.delete(listener); 35 this._listeners.delete(listener);
36 }, 36 },
37 _dispatch(...args) 37 _dispatch(...args)
38 { 38 {
39 let results = []; 39 let results = [];
40 let listeners = [...this._listeners];
41 40
42 for (let listener of listeners) 41 for (let listener of this._listeners)
43 results.push(listener(...args)); 42 results.push(listener(...args));
44 43
45 return results; 44 return results;
46 } 45 }
47 }; 46 };
48 47
49 // Workaround since HTMLCollection and NodeList didn't have iterator support 48 // Workaround since HTMLCollection and NodeList didn't have iterator support
50 // before Chrome 51. 49 // before Chrome 51.
51 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 50 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699
52 let arrayIterator = Array.prototype[Symbol.iterator]; 51 let arrayIterator = Array.prototype[Symbol.iterator];
(...skipping 16 matching lines...) Expand all
69 return chrome.extension.getBackgroundPage(); 68 return chrome.extension.getBackgroundPage();
70 } 69 }
71 }; 70 };
72 71
73 72
74 /* Utils */ 73 /* Utils */
75 74
76 ext.getURL = chrome.extension.getURL; 75 ext.getURL = chrome.extension.getURL;
77 ext.i18n = chrome.i18n; 76 ext.i18n = chrome.i18n;
78 }()); 77 }());
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld