Opened on 10/03/2018 at 01:12:56 PM

Closed on 02/19/2019 at 09:18:35 PM

Last modified on 04/16/2020 at 11:37:47 AM

#7016 closed change (fixed)

Convert serialization functions into generators

Reported by: mjethani Assignee: jsonesen
Priority: P3 Milestone:
Module: Core Keywords:
Cc: jsonesen, sebastian, erikvold Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29900557/

Description (last modified by mjethani)

Background

The serialization functions in the Filter and Subscripton classes look somewhat like this (pseudocode):

/**
 * @param {string[]} buffer
 */
function serialize(buffer)
{
  buffer.push("[Filter]");
  buffer.push("text=" + this.text);
}

The exportData function in lib/filterStorage.js has code like this:

let buffer = [];
for (let filter of filters)
{
  filter.serialize(buffer);
  for (let line of buffer)
    yield line;
  buffer.splice(0);
}

exportData is a generator function. It is wasteful to create a temporary array, pass it to the serialization function for each filter, and empty it out for the next filter in the list. Instead, the serialization function could also be a generator that yields each "line" to be serialized.

With this change, the code in exportData would look like this instead:

for (let filter of filters)
  yield* filter.serialize();

What to change

Convert the serialization functions in the Filter and Subscription classes to generators, and make the corresponding changes in the exportData function.

Tips for testers

Ensure custom filters added from the options page, and the devtools panel persists between browser restarts (see hints in #6893).

Also try the following:

  1. Subscribe to a filter list
  2. Try a filter from the filter list, it should work
  3. Reload the extension and try the filter again, it should work
  4. Disable the subscription, reload the extension, and try the filter again, it should no longer work
  5. Enable the subscription, reload the extension, and try the filter again, it should work again
  6. Remove the subscription (click the trash icon), reload the extension, and try the filter again, it should once again no longer work

Attachments (0)

Change History (13)

comment:1 Changed on 10/03/2018 at 02:54:45 PM by jsonesen

  • Owner set to jsonesen

comment:2 Changed on 10/04/2018 at 01:37:53 PM by sebastian

  • Cc sebastian added

Please add some integration notes to adapt this code in
adblockpluschrome which currently relies on subscription's serialize() and serializeFilters() methods to take an array as an argument.

comment:3 Changed on 10/24/2018 at 03:17:50 PM by abpbot

A commit referencing this issue has landed:
Issue 7016 - Convert serialization functions into generators

comment:4 Changed on 11/15/2018 at 04:35:13 AM by erikvold

  • Cc erikvold added

comment:5 Changed on 01/30/2019 at 06:34:29 PM by jsonesen

  • Resolution set to fixed
  • Status changed from new to closed

comment:6 Changed on 02/05/2019 at 11:18:15 AM by mjethani

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:7 follow-up: Changed on 02/05/2019 at 11:18:47 AM by mjethani

Hey Jon,

I have reopened this because it doesn't have a "Hints for testers" section. We need this.

Last edited on 02/05/2019 at 11:18:58 AM by mjethani

comment:8 in reply to: ↑ 7 Changed on 02/05/2019 at 11:40:14 PM by jsonesen

Replying to mjethani:

Hey Jon,

I have reopened this because it doesn't have a "Hints for testers" section. We need this.

Good catch, I woefully neglected this ticket when I landed the change I will fix this.

comment:9 Changed on 02/07/2019 at 03:23:45 AM by abpbot

A commit referencing this issue has landed:
Issue 7016 - Convert serialization functions into generators

comment:10 Changed on 02/19/2019 at 09:18:35 PM by jsonesen

  • Description modified (diff)
  • Resolution set to fixed
  • Status changed from reopened to closed

comment:11 Changed on 02/20/2019 at 04:52:57 AM by mjethani

  • Description modified (diff)

comment:12 Changed on 02/21/2019 at 09:39:09 AM by ukacar

  • Verified working set

comment:13 Changed on 04/16/2020 at 11:37:47 AM by mjethani

  • Review URL(s) modified (diff)

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from jsonesen.
 
Note: See TracTickets for help on using tickets.