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

Issue 29800603: Noissue - Remove redundant assignment to zero (Closed)

Created:
June 6, 2018, 5:35 p.m. by Manish Jethani
Modified:
June 7, 2018, 2:39 p.m.
Reviewers:
sergei, kzar
Base URL:
https://hg.adblockplus.org/adblockpluscore/
Visibility:
Public.

Description

Noissue - Remove redundant assignment to zero

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+0 lines, -2 lines) Patch
M lib/filterClasses.js View 1 chunk +0 lines, -2 lines 4 comments Download

Messages

Total messages: 6
Manish Jethani
June 6, 2018, 5:36 p.m. (2018-06-06 17:36:05 UTC) #1
Manish Jethani
Patch Set 1 null and 0 are the same as far as bitwise operations are ...
June 6, 2018, 5:37 p.m. (2018-06-06 17:37:08 UTC) #2
kzar
https://codereview.adblockplus.org/29800603/diff/29800604/lib/filterClasses.js File lib/filterClasses.js (left): https://codereview.adblockplus.org/29800603/diff/29800604/lib/filterClasses.js#oldcode735 lib/filterClasses.js:735: let contentType = null; It's kinda confusing to reason ...
June 7, 2018, 1:34 p.m. (2018-06-07 13:34:55 UTC) #3
Manish Jethani
https://codereview.adblockplus.org/29800603/diff/29800604/lib/filterClasses.js File lib/filterClasses.js (left): https://codereview.adblockplus.org/29800603/diff/29800604/lib/filterClasses.js#oldcode735 lib/filterClasses.js:735: let contentType = null; On 2018/06/07 13:34:55, kzar wrote: ...
June 7, 2018, 2:23 p.m. (2018-06-07 14:23:32 UTC) #4
kzar
LGTM https://codereview.adblockplus.org/29800603/diff/29800604/lib/filterClasses.js File lib/filterClasses.js (left): https://codereview.adblockplus.org/29800603/diff/29800604/lib/filterClasses.js#oldcode735 lib/filterClasses.js:735: let contentType = null; On 2018/06/07 14:23:31, Manish ...
June 7, 2018, 2:32 p.m. (2018-06-07 14:32:32 UTC) #5
Manish Jethani
June 7, 2018, 2:38 p.m. (2018-06-07 14:38:23 UTC) #6
On 2018/06/07 14:32:32, kzar wrote:
> LGTM

Thanks!

https://codereview.adblockplus.org/29800603/diff/29800604/lib/filterClasses.js
File lib/filterClasses.js (left):

https://codereview.adblockplus.org/29800603/diff/29800604/lib/filterClasses.j...
lib/filterClasses.js:735: let contentType = null;
On 2018/06/07 14:32:32, kzar wrote:
> On 2018/06/07 14:23:31, Manish Jethani wrote:
> > In theory one could write a filter that specifically disables the filter on
> every single content type, thus yielding the value 0 in the end.
> 
> Yea, I guess you're right. It seems kind of unlikely that a filter explicitly
> disables every single content type once, then one again... but if it did I
guess
> the result would be `RegExpFilter.prototype.contentType & ~contentType`
instead
> of `0 & ~contentType` without the null.

If every single type is excluded the final value of contentType would be 0, also
the initial value. Then the RegExpFilter constructor would have the following
check:

  if (contentType != 0)
    this.contentType = contentType;

So for 0 it would result in applying the filter to all content types - the
opposite of what the filter author intended. With null we avoid this.

Powered by Google App Engine
This is Rietveld