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

Issue 29719569: Issue 6467 - Use Map object for caching filter matches (Closed)

Created:
March 10, 2018, 3:30 p.m. by Manish Jethani
Modified:
March 13, 2018, 2:40 p.m.
Reviewers:
sergei, kzar
CC:
hub
Base URL:
https://hg.adblockplus.org/adblockpluscore/
Visibility:
Public.

Description

See issue description at https://issues.adblockplus.org/ticket/6467

Patch Set 1 #

Total comments: 11

Patch Set 2 : Use typeof #

Unified diffs Side-by-side diffs Delta from patch set Stats (+14 lines, -31 lines) Patch
M lib/matcher.js View 1 3 chunks +14 lines, -31 lines 0 comments Download

Messages

Total messages: 9
Manish Jethani
March 10, 2018, 3:30 p.m. (2018-03-10 15:30:34 UTC) #1
Manish Jethani
Patch Set 1 https://codereview.adblockplus.org/29719569/diff/29719570/lib/matcher.js File lib/matcher.js (left): https://codereview.adblockplus.org/29719569/diff/29719570/lib/matcher.js#oldcode282 lib/matcher.js:282: * Number of entries in resultCache ...
March 10, 2018, 3:54 p.m. (2018-03-10 15:54:38 UTC) #2
sergei
Could you please file the issue for it and move that long description with profiling ...
March 12, 2018, 12:03 p.m. (2018-03-12 12:03:01 UTC) #3
Manish Jethani
On 2018/03/12 12:03:01, sergei wrote: > Could you please file the issue for it and ...
March 12, 2018, 1:42 p.m. (2018-03-12 13:42:42 UTC) #4
Manish Jethani
On 2018/03/12 13:42:42, Manish Jethani wrote: > On 2018/03/12 12:03:01, sergei wrote: > > > ...
March 12, 2018, 1:52 p.m. (2018-03-12 13:52:51 UTC) #5
sergei
On 2018/03/12 13:52:51, Manish Jethani wrote: > On 2018/03/12 13:42:42, Manish Jethani wrote: > > ...
March 12, 2018, 5:48 p.m. (2018-03-12 17:48:32 UTC) #6
Manish Jethani
Patch Set 2: Use typeof https://codereview.adblockplus.org/29719569/diff/29719570/lib/matcher.js File lib/matcher.js (right): https://codereview.adblockplus.org/29719569/diff/29719570/lib/matcher.js#newcode414 lib/matcher.js:414: if (result !== undefined) ...
March 12, 2018, 6:59 p.m. (2018-03-12 18:59:21 UTC) #7
sergei
LGTM https://codereview.adblockplus.org/29719569/diff/29719570/lib/matcher.js File lib/matcher.js (right): https://codereview.adblockplus.org/29719569/diff/29719570/lib/matcher.js#newcode414 lib/matcher.js:414: if (result !== undefined) On 2018/03/12 18:59:21, Manish ...
March 13, 2018, 1:56 p.m. (2018-03-13 13:56:41 UTC) #8
Manish Jethani
March 13, 2018, 2:32 p.m. (2018-03-13 14:32:49 UTC) #9
On 2018/03/13 13:56:41, sergei wrote:
> LGTM

Thanks!

https://codereview.adblockplus.org/29719569/diff/29719570/lib/matcher.js
File lib/matcher.js (right):

https://codereview.adblockplus.org/29719569/diff/29719570/lib/matcher.js#newc...
lib/matcher.js:414: if (result !== undefined)
On 2018/03/13 13:56:41, sergei wrote:
> On 2018/03/12 18:59:21, Manish Jethani wrote:
> > On 2018/03/12 17:48:31, sergei wrote:
> > > On 2018/03/12 13:42:42, Manish Jethani wrote:
> > > > On 2018/03/12 12:03:01, sergei wrote:
> > > > > On 2018/03/10 15:54:37, Manish Jethani wrote:
> > > > > > Assumption: an entry will never have a value of undefined. I checked
> and
> > > > we're
> > > > > > not setting the value to undefined (directly or indirectly)
anywhere.
> > > > > 
> > > > > AFAIK our coding style says to rather use `typeof result !=
> "undefined"`,
> > > > though
> > > > > I find `result !== undefined` better. Let's discuss it in #eyeo-js.
> > > > 
> > > > This is really not about coding style. The cache can have a legitimate
> entry
> > > > with a value of null, which is equal to undefined using non-strict
> equality.
> > > If
> > > > we want to find out if the cache actually has no entry for the given
key,
> we
> > > > have to compare with undefined using strict equality.
> > > > 
> > > > The alternative would be to use Map.has but then we'd be doing an extra
> > > lookup,
> > > > which is what I find is unnecessary.
> > > 
> > > Please take a look around in this file, whenever one could use `!==
> > undefined`,
> > > `typeof ...` is used. In addition typeof does not conflict with having
null
> > > values because `typeof null` is "object".
> > > 
> > > BTW, currently I cannot find that in the coding style but I'm pretty sure
> that
> > > it was there because I had written the same code several times and several
> > times
> > > someone told me about that.
> > 
> > Done.
> 
> I still think we should discuss whether we use typeof == "undefined" or !==
> undefined in IRC.

Yes, let's have that discussion.

Powered by Google App Engine
This is Rietveld