Skip to content

Commit

Permalink
lib: simplify 'processChunkSync'
Browse files Browse the repository at this point in the history
According to the real logic codes, it seems no matter whether 'nread >=
kMaxLength' or not. We always close the 'self' stream first. So we can
shorten it by merging them into one sample.

PR-URL: #22802
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
  • Loading branch information
MaleDong authored and targos committed Sep 20, 2018
1 parent f0a4017 commit 49b5933
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,14 +527,12 @@ function processChunkSync(self, chunk, flushFlag) {
}

self.bytesWritten = inputRead;
_close(self);

if (nread >= kMaxLength) {
_close(self);
throw new ERR_BUFFER_TOO_LARGE();
}

_close(self);

if (nread === 0)
return Buffer.alloc(0);

Expand Down

0 comments on commit 49b5933

Please sign in to comment.