Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: fixed unreachable if statements in zlib #24190

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,7 @@ Object.defineProperty(Zlib.prototype, 'bytesRead', {
// `params()` function should not happen while a write is currently in progress
// on the threadpool.
function paramsAfterFlushCallback(level, strategy, callback) {
if (!this._handle)
Copy link
Member

@lpinca lpinca Nov 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was an optimization to avoid an unnecessary function call in the common case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should not be a significant overhead. Such a micro optimization should not have any impact on a real application.

assert(false, 'zlib binding closed');
assert(this._handle, 'zlib binding closed');
this._handle.params(level, strategy);
if (!this._hadError) {
this._level = level;
Expand Down Expand Up @@ -507,8 +506,8 @@ function processChunkSync(self, chunk, flushFlag) {
else
buffers.push(out);
nread += out.byteLength;
} else if (have < 0) {
assert(false, 'have should not go down');
} else {
assert(have === 0, 'have should not go down');
}

// exhausted the output buffer, or used all the input create a new one.
Expand Down Expand Up @@ -545,8 +544,7 @@ function processChunkSync(self, chunk, flushFlag) {

function processChunk(self, chunk, flushFlag, cb) {
var handle = self._handle;
if (!handle)
assert(false, 'zlib binding closed');
assert(handle, 'zlib binding closed');

handle.buffer = chunk;
handle.cb = cb;
Expand Down Expand Up @@ -593,8 +591,8 @@ function processCallback() {
var out = self._outBuffer.slice(self._outOffset, self._outOffset + have);
self._outOffset += have;
self.push(out);
} else if (have < 0) {
assert(false, 'have should not go down');
} else {
assert(have === 0, 'have should not go down');
}

if (self.destroyed) {
Expand Down