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: Actually address nits Created Oct. 23, 2018, 3:21 a.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
« no previous file with comments | « lib/filterClasses.js ('k') | lib/subscriptionClasses.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterStorage.js
===================================================================
--- a/lib/filterStorage.js
+++ b/lib/filterStorage.js
@@ -481,46 +481,33 @@
subscriptions.push(subscription);
}
}
yield "# Adblock Plus preferences";
yield "version=" + this.formatVersion;
let saved = new Set();
- let buf = [];
// Save subscriptions
for (let subscription of subscriptions)
{
- yield "";
-
- subscription.serialize(buf);
- if (subscription.filters.length)
- {
- buf.push("", "[Subscription filters]");
- subscription.serializeFilters(buf);
- }
- for (let line of buf)
- yield line;
- buf.splice(0);
+ yield* subscription.serialize();
+ yield* subscription.serializeFilters();
}
// 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);
}
}
}
}
/**
* Saves all subscriptions back to disk.
* @returns {Promise} A promise resolved or rejected when saving is complete.
« no previous file with comments | « lib/filterClasses.js ('k') | lib/subscriptionClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld