Left: | ||
Right: |
OLD | NEW |
---|---|
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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 subscription.filters.length == 0)) | 452 subscription.filters.length == 0)) |
453 { | 453 { |
454 subscriptions.push(subscription); | 454 subscriptions.push(subscription); |
455 } | 455 } |
456 } | 456 } |
457 | 457 |
458 yield "# Adblock Plus preferences"; | 458 yield "# Adblock Plus preferences"; |
459 yield "version=" + formatVersion; | 459 yield "version=" + formatVersion; |
460 | 460 |
461 let saved = new Set(); | 461 let saved = new Set(); |
462 let buf = []; | |
463 | 462 |
464 // Save subscriptions | 463 // Save subscriptions |
465 for (let subscription of subscriptions) | 464 for (let subscription of subscriptions) |
466 { | 465 { |
467 yield ""; | 466 yield* subscription.serialize(); |
Manish Jethani
2018/10/04 03:37:12
I think we still need the blank line.
Manish Jethani
2018/10/04 04:50:11
Oh, it seems blank lines are really not necessary,
Jon Sonesen
2018/10/06 00:06:32
I thought that this was iniparser processes each l
Manish Jethani
2018/10/09 15:11:03
Yeah, blank lines are ignored [1]
[1]: https://gi
| |
468 | 467 |
469 subscription.serialize(buf); | |
470 if (subscription.filters.length) | 468 if (subscription.filters.length) |
Manish Jethani
2018/10/04 04:08:59
One thing worth noting here as that before this ch
Manish Jethani
2018/10/04 04:17:06
Additionally, it should never be possible for this
Manish Jethani
2018/10/04 04:36:23
Alright, some more thinking about this. Let's do t
Manish Jethani
2018/10/04 05:10:06
Sorry, I mean `yield*` here.
Manish Jethani
2018/10/04 06:10:15
I profiled this. It performs slightly better than
Jon Sonesen
2018/10/06 00:06:32
So, I had similar concerns. But figured we can has
Manish Jethani
2018/10/09 15:11:03
Alright, let's do this properly.
So the strategy
Jon Sonesen
2018/10/12 03:50:05
Spent an embarrassing amount of time trying to fig
Manish Jethani
2018/10/14 20:05:36
Ack.
Yeah, this was just a description.
| |
471 { | 469 { |
472 buf.push("", "[Subscription filters]"); | 470 yield "[Subscription filters]"; |
Manish Jethani
2018/10/04 04:08:59
We would have to yield a blank line here before yi
Jon Sonesen
2018/10/06 00:06:34
See my comment above :)
Manish Jethani
2018/10/09 15:11:03
Acknowledged.
| |
473 subscription.serializeFilters(buf); | 471 yield* subscription.serializeFilters(); |
474 } | 472 } |
475 for (let line of buf) | |
476 yield line; | |
477 buf.splice(0); | |
478 } | 473 } |
479 | 474 |
480 // Save filter data | 475 // Save filter data |
481 for (let subscription of subscriptions) | 476 for (let subscription of subscriptions) |
482 { | 477 { |
483 for (let filter of subscription.filters) | 478 for (let filter of subscription.filters) |
484 { | 479 { |
485 if (!saved.has(filter.text)) | 480 if (!saved.has(filter.text)) |
486 { | 481 { |
487 filter.serialize(buf); | 482 yield* filter.serialize(); |
488 saved.add(filter.text); | 483 saved.add(filter.text); |
489 for (let line of buf) | |
490 yield line; | |
491 buf.splice(0); | |
492 } | 484 } |
493 } | 485 } |
494 } | 486 } |
495 }, | 487 }, |
496 | 488 |
497 /** | 489 /** |
498 * Will be set to true if saveToDisk() is running (reentrance protection). | 490 * Will be set to true if saveToDisk() is running (reentrance protection). |
499 * @type {boolean} | 491 * @type {boolean} |
500 */ | 492 */ |
501 _saving: false, | 493 _saving: false, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
654 * @param {Subscription} subscription filter subscription to be removed | 646 * @param {Subscription} subscription filter subscription to be removed |
655 */ | 647 */ |
656 function removeSubscriptionFilters(subscription) | 648 function removeSubscriptionFilters(subscription) |
657 { | 649 { |
658 if (!FilterStorage.knownSubscriptions.has(subscription.url)) | 650 if (!FilterStorage.knownSubscriptions.has(subscription.url)) |
659 return; | 651 return; |
660 | 652 |
661 for (let filter of subscription.filters) | 653 for (let filter of subscription.filters) |
662 filter.removeSubscription(subscription); | 654 filter.removeSubscription(subscription); |
663 } | 655 } |
OLD | NEW |