Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 let source = this.domainSource; | 376 let source = this.domainSource; |
377 if (!this.domainSourceIsUpperCase) | 377 if (!this.domainSourceIsUpperCase) |
378 { | 378 { |
379 // RegExpFilter already have uppercase domains | 379 // RegExpFilter already have uppercase domains |
380 source = source.toUpperCase(); | 380 source = source.toUpperCase(); |
381 } | 381 } |
382 let list = source.split(this.domainSeparator); | 382 let list = source.split(this.domainSeparator); |
383 if (list.length == 1 && list[0][0] != "~") | 383 if (list.length == 1 && list[0][0] != "~") |
384 { | 384 { |
385 // Fast track for the common one-domain scenario | 385 // Fast track for the common one-domain scenario |
386 domains = new Map(); | |
387 domains.set("", false); | |
388 if (this.ignoreTrailingDot) | 386 if (this.ignoreTrailingDot) |
389 list[0] = list[0].replace(/\.+$/, ""); | 387 list[0] = list[0].replace(/\.+$/, ""); |
390 domains.set(list[0], true); | 388 domains = new Map([["", false], [list[0], true]]); |
Wladimir Palant
2017/09/21 08:11:44
You can initialize the Map object immediately: new
sergei
2017/09/21 10:50:34
Done. BTW, I would like to pay attention to the im
Wladimir Palant
2017/09/21 10:53:01
Feel free to measure that. I assume that the JS en
| |
391 } | 389 } |
392 else | 390 else |
393 { | 391 { |
394 let hasIncludes = false; | 392 let hasIncludes = false; |
395 for (let i = 0; i < list.length; i++) | 393 for (let i = 0; i < list.length; i++) |
396 { | 394 { |
397 let domain = list[i]; | 395 let domain = list[i]; |
398 if (this.ignoreTrailingDot) | 396 if (this.ignoreTrailingDot) |
399 domain = domain.replace(/\.+$/, ""); | 397 domain = domain.replace(/\.+$/, ""); |
400 if (domain == "") | 398 if (domain == "") |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 if (!docDomain) | 458 if (!docDomain) |
461 return this.domains.get(""); | 459 return this.domains.get(""); |
462 | 460 |
463 if (this.ignoreTrailingDot) | 461 if (this.ignoreTrailingDot) |
464 docDomain = docDomain.replace(/\.+$/, ""); | 462 docDomain = docDomain.replace(/\.+$/, ""); |
465 docDomain = docDomain.toUpperCase(); | 463 docDomain = docDomain.toUpperCase(); |
466 | 464 |
467 while (true) | 465 while (true) |
468 { | 466 { |
469 let isDomainIncluded = this.domains.get(docDomain); | 467 let isDomainIncluded = this.domains.get(docDomain); |
470 if (isDomainIncluded != undefined) | 468 if (typeof isDomainIncluded != "undefined") |
Wladimir Palant
2017/09/21 08:11:44
We usually use the typeof operator: `typeof isDoma
sergei
2017/09/21 10:50:34
Acknowledged.
| |
471 return isDomainIncluded; | 469 return isDomainIncluded; |
472 | 470 |
473 let nextDot = docDomain.indexOf("."); | 471 let nextDot = docDomain.indexOf("."); |
474 if (nextDot < 0) | 472 if (nextDot < 0) |
475 break; | 473 break; |
476 docDomain = docDomain.substr(nextDot + 1); | 474 docDomain = docDomain.substr(nextDot + 1); |
477 } | 475 } |
478 return this.domains.get(""); | 476 return this.domains.get(""); |
479 }, | 477 }, |
480 | 478 |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1021 */ | 1019 */ |
1022 function ElemHideEmulationFilter(text, domains, selector) | 1020 function ElemHideEmulationFilter(text, domains, selector) |
1023 { | 1021 { |
1024 ElemHideBase.call(this, text, domains, selector); | 1022 ElemHideBase.call(this, text, domains, selector); |
1025 } | 1023 } |
1026 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; | 1024 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; |
1027 | 1025 |
1028 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { | 1026 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { |
1029 type: "elemhideemulation" | 1027 type: "elemhideemulation" |
1030 }); | 1028 }); |
LEFT | RIGHT |