Opened on 01/31/2019 at 12:22:58 PM

Closed on 02/05/2019 at 09:11:31 AM

Last modified on 02/07/2019 at 03:24:10 AM

#7250 closed change (fixed)

Optimize third-party request check

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

https://codereview.adblockplus.org/29994555/

Description (last modified by mjethani)

Background

In #7232 the third-party request checking code was moved into adblockpluscore. This code is one of the hot spots, and now it can be optimized using some simple tricks:

  • Use a Map object rather than a plain object
  • Avoid Array.prototype.split and Array.prototype.join, instead use a while loop and String.prototype.indexOf
  • Avoid String.prototype.replace with a regular expression unless required
  • Split into smaller generic functions for later reuse

What to change

Make the above changes.

Hints for testers

Make sure that filters with $third-party and ~third-party (not third-party, i.e. first-party) flags are working as expected. For example, the filter foo$third-party should block a request to http://foo.com/foo from http://bar.com/ but not from http://foo.com/ itself. Similarly, the filter bar$~third-party should block a request to http://bar.com/bar from http://bar.com/ but not from http://foo.com/.

Note that the significant part of the change here is figuring out what "third-party" means. foo.example.com and bar.example.com are considered to be the same domain; therefore, a request from one to the other is not third-party. But foo.com and bar.com are not the same domain, therefore a request from one to the other is third-party. Please test for this.

Attachments (0)

Change History (8)

comment:1 Changed on 01/31/2019 at 12:26:58 PM by mjethani

  • Review URL(s) modified (diff)

comment:2 Changed on 01/31/2019 at 12:27:36 PM by mjethani

  • Priority changed from Unknown to P2
  • Ready set

comment:3 Changed on 01/31/2019 at 12:27:46 PM by mjethani

  • Owner set to mjethani

comment:4 Changed on 01/31/2019 at 12:27:59 PM by mjethani

  • Status changed from new to reviewing

comment:5 Changed on 02/04/2019 at 11:06:49 PM by abpbot

A commit referencing this issue has landed:
Issue 7250 - Optimize third-party request check

comment:6 Changed on 02/05/2019 at 09:11:31 AM by mjethani

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

comment:7 Changed on 02/05/2019 at 09:17:54 AM by mjethani

  • Description modified (diff)

comment:8 Changed on 02/07/2019 at 03:24:10 AM by abpbot

A commit referencing this issue has landed:
Issue 7250 - Optimize third-party request check

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 mjethani.
 
Note: See TracTickets for help on using tickets.