Remove an impossible check in Reader.prototype.readLength
#55
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Removes the impossible "if (lenB === null)" check, since it is impossible for it to be null because of the "& 0xff" on the previous line.
According the the spec (https://262.ecma-international.org/#sec-numberbitwiseop), the result of
this._buf[offset++] & 0xff
(call to the internalNumberBitwiseOp(&, this._buf[offset++], 0xff)
) must be an integer unless it throws. It may throw becauseToInt32
(https://262.ecma-international.org/#sec-toint32) callsToNumber
(https://262.ecma-international.org/#sec-tonumber) which throws if the argument is a Symbol or BigInt. I tested many combinations ofthing & 0xff
in multiple versions of Node; and have not yet found a case where this part of the spec is false.Since it may never be null, the lines 93 and 94 that say
if (lenB === null) return null
are basically a no-op.Removing it should not be a breaking change for anyone.
It's not much, but it may shave off a few bytes and CPU cycles.