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

Side by Side Diff: options.js

Issue 29417597: Issue 5161 - Use maps and sets where appropriate (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Minor unrelated changes Created May 21, 2017, 10:15 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 | « lib/whitelisting.js ('k') | 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 * taking any values as specified by the paramKeys 30 * taking any values as specified by the paramKeys
31 * and finally an optional callback. (Although the 31 * and finally an optional callback. (Although the
32 * value arguments are optional their index must be 32 * value arguments are optional their index must be
33 * maintained. E.g. if you omit the first value you 33 * maintained. E.g. if you omit the first value you
34 * must omit the second too.) 34 * must omit the second too.)
35 */ 35 */
36 function wrapper(baseMessage, ...paramKeys) 36 function wrapper(baseMessage, ...paramKeys)
37 { 37 {
38 return function(...paramValues /* , callback */) 38 return function(...paramValues /* , callback */)
39 { 39 {
40 let message = Object.create(null); 40 let message = Object.assign(Object.create(null), baseMessage);
41 for (let key in baseMessage)
42 {
43 if (baseMessage.hasOwnProperty(key))
44 message[key] = baseMessage[key];
45 }
46
47 let callback; 41 let callback;
48 42
49 if (paramValues.length > 0) 43 if (paramValues.length > 0)
50 { 44 {
51 let lastArg = paramValues[paramValues.length - 1]; 45 let lastArg = paramValues[paramValues.length - 1];
52 if (typeof lastArg == "function") 46 if (typeof lastArg == "function")
53 callback = lastArg; 47 callback = lastArg;
54 48
55 for (let i = 0; i < paramValues.length - (callback ? 1 : 0); i++) 49 for (let i = 0; i < paramValues.length - (callback ? 1 : 0); i++)
56 message[paramKeys[i]] = paramValues[i]; 50 message[paramKeys[i]] = paramValues[i];
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 onFilterMessage(message.action, message.args[0]); 733 onFilterMessage(message.action, message.args[0]);
740 break; 734 break;
741 case "prefs.respond": 735 case "prefs.respond":
742 onPrefMessage(message.action, message.args[0]); 736 onPrefMessage(message.action, message.args[0]);
743 break; 737 break;
744 case "subscriptions.respond": 738 case "subscriptions.respond":
745 onSubscriptionMessage(message.action, message.args[0]); 739 onSubscriptionMessage(message.action, message.args[0]);
746 break; 740 break;
747 } 741 }
748 }); 742 });
OLDNEW
« no previous file with comments | « lib/whitelisting.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld