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

Unified Diff: lib/filterStorage.js

Issue 29900557: Issue 7016 - Convert serialization functions into generators (Closed)
Patch Set: Remove unelated change Created Oct. 3, 2018, 11:51 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/filterStorage.js
===================================================================
--- a/lib/filterStorage.js
+++ b/lib/filterStorage.js
@@ -454,46 +454,38 @@
subscriptions.push(subscription);
}
}
yield "# Adblock Plus preferences";
yield "version=" + formatVersion;
let saved = new Set();
- let buf = [];
// Save subscriptions
for (let subscription of subscriptions)
{
- yield "";
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
+ yield* subscription.serialize();
- subscription.serialize(buf);
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.
{
- buf.push("", "[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.
- subscription.serializeFilters(buf);
+ yield "[Subscription filters]";
+ yield* subscription.serializeFilters();
}
- for (let line of buf)
- yield line;
- buf.splice(0);
}
// Save filter data
for (let subscription of subscriptions)
{
for (let filter of subscription.filters)
{
if (!saved.has(filter.text))
{
- filter.serialize(buf);
+ yield* filter.serialize();
saved.add(filter.text);
- for (let line of buf)
- yield line;
- buf.splice(0);
}
}
}
},
/**
* Will be set to true if saveToDisk() is running (reentrance protection).
* @type {boolean}

Powered by Google App Engine
This is Rietveld