From 49b59334d066fefb76e45a817c1760ca986d1ff0 Mon Sep 17 00:00:00 2001 From: MaleDong Date: Tue, 11 Sep 2018 11:55:03 +0800 Subject: [PATCH] lib: simplify 'processChunkSync' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/pull/22802 Reviewed-By: Tobias Nießen Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Weijia Wang --- lib/zlib.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/zlib.js b/lib/zlib.js index ca5f05884ad3c0..87e8641767669f 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -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);