Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#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.

Change History (8)

comment:1 Changed 8 months ago by mjethani

  • Review URL(s) modified (diff)

comment:2 Changed 8 months ago by mjethani

  • Priority changed from Unknown to P2
  • Ready set

comment:3 Changed 8 months ago by mjethani

  • Owner set to mjethani

comment:4 Changed 8 months ago by mjethani

  • Status changed from new to reviewing

comment:5 Changed 8 months ago by abpbot

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

comment:6 Changed 8 months ago by mjethani

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

comment:7 Changed 8 months ago by mjethani

  • Description modified (diff)

comment:8 Changed 8 months ago by abpbot

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

Note: See TracTickets for help on using tickets.