-
Notifications
You must be signed in to change notification settings - Fork 28.6k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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) | ||||||
assert(false, 'zlib binding closed'); | ||||||
assert(this._handle, 'zlib binding closed'); | ||||||
this._handle.params(level, strategy); | ||||||
if (!this._hadError) { | ||||||
this._level = level; | ||||||
|
@@ -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'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not obvious from looking at the code why that check is sufficient. Do you have a small description why? :) |
||||||
} | ||||||
|
||||||
// exhausted the output buffer, or used all the input create a new one. | ||||||
|
@@ -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; | ||||||
|
@@ -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'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
if (self.destroyed) { | ||||||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.