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

Unified Diff: lib/filterStorage.js

Issue 29899601: Issue 7015 - Serialize subscriptions for *exportData in one loop (Closed)
Patch Set: Created Oct. 3, 2018, 3:53 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
« no previous file with comments | « no previous file | no next file » | 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
@@ -438,49 +438,44 @@
});
},
/**
* Generator serializing filter data and yielding it line by line.
*/
*exportData()
{
- // Do not persist external subscriptions
- let subscriptions = [];
- for (let subscription of this.subscriptions())
- {
- if (!(subscription instanceof ExternalSubscription))
- subscriptions.push(subscription);
- }
-
yield "# Adblock Plus preferences";
yield "version=" + formatVersion;
let saved = new Set();
let buf = [];
// Save subscriptions
- for (let subscription of subscriptions)
+ for (let subscription of this.subscriptions())
{
+ // Do not persist external subscriptions
+ if (subscription instanceof ExternalSubscription)
+ continue;
+
yield "";
+ subscription.serialize(buf);
- subscription.serialize(buf);
if (subscription.filters.length)
{
buf.push("", "[Subscription filters]");
subscription.serializeFilters(buf);
}
+
for (let line of buf)
yield line;
- buf.splice(0);
- }
- // Save filter data
- for (let subscription of subscriptions)
- {
+ buf.splice(0);
Sebastian Noack 2018/10/03 16:33:24 While optimizing this code, you might want conside
+
+ // Save filter data
for (let filter of subscription.filters)
{
if (!saved.has(filter.text))
{
filter.serialize(buf);
saved.add(filter.text);
for (let line of buf)
yield line;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld