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

Delta Between Two Patch Sets: lib/elemHide.js

Issue 29882562: Issue 6956 - Move extension's style sheet generation into core (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Make createStyleSheet top-level Created Sept. 18, 2018, 2:57 p.m.
Right Patch Set: Avoid temporary array and join Created Sept. 18, 2018, 3:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | test/elemHide.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 /** 278 /**
279 * Creates element hiding CSS rules for a given list of selectors. Each rule 279 * Creates element hiding CSS rules for a given list of selectors. Each rule
280 * contains no more than the maximum number of selectors as determined by the 280 * contains no more than the maximum number of selectors as determined by the
281 * value of <code>{@link selectorGroupSize}</code>. 281 * value of <code>{@link selectorGroupSize}</code>.
282 * 282 *
283 * @param {Array.<string>} selectors 283 * @param {Array.<string>} selectors
284 * @yields {string} 284 * @yields {string}
285 */ 285 */
286 function* createRules(selectors) 286 function* createRules(selectors)
287 { 287 {
288 for (let selectorGroup of splitSelectors(selectors)) 288 for (let selectorGroup of splitSelectors(selectors))
Sebastian Noack 2018/09/18 15:33:24 Since splitSelectors() is only called from one cod
Manish Jethani 2018/09/18 15:50:02 I tried this and it seems to actually perform slig
Sebastian Noack 2018/09/18 16:41:45 V8 optimizes functions regardless of size, however
Manish Jethani 2018/09/18 17:24:07 There is a specific optimization in TurboFan calle
Sebastian Noack 2018/09/18 17:40:54 This appears rather odd to me. On which version of
Manish Jethani 2018/09/18 17:47:46 I did it on Chrome 71 (Canary). It's not going to
Manish Jethani 2018/09/18 19:51:57 Alright, here we go. The alternative version of t
Sebastian Noack 2018/09/18 21:21:03 I think the main target for any benchmark should a
Manish Jethani 2018/09/19 09:39:00 A lot of the best programmers would disagree that
Manish Jethani 2018/09/19 10:18:33 Since I was modifying the `createStyleSheet` funct
Manish Jethani 2018/09/19 10:29:08 Also: https://arstechnica.com/information-technolo
Sebastian Noack 2018/09/19 11:05:53 I'm obviously not trying to argue that functions s
Manish Jethani 2018/09/19 13:14:41 If they are logically separate (as in, the program
Jon Sonesen 2018/09/19 16:36:26 FWIW I would say that Manish is right about contex
289 yield selectorGroup.join(", ") + " {display: none !important;}"; 289 yield selectorGroup.join(", ") + " {display: none !important;}";
290 } 290 }
291 291
292 /** 292 /**
293 * Creates an element hiding CSS style sheet from a given list of selectors. 293 * Creates an element hiding CSS style sheet from a given list of selectors.
294 * @param {Array.<string>} selectors 294 * @param {Array.<string>} selectors
295 * @returns {string} 295 * @returns {string}
296 */ 296 */
297 function createStyleSheet(selectors) 297 function createStyleSheet(selectors)
298 { 298 {
299 return [...createRules(selectors)].join("\n"); 299 let styleSheet = "";
300
301 for (let rule of createRules(selectors))
302 styleSheet += rule + "\n";
303
304 return styleSheet;
300 } 305 }
301 306
302 exports.createStyleSheet = createStyleSheet; 307 exports.createStyleSheet = createStyleSheet;
LEFTRIGHT
« no previous file | test/elemHide.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld