Skip to content

Commit 49b5933

Browse files
MaleDongtargos
MaleDong
authored andcommitted
lib: simplify 'processChunkSync'
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 <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Weijia Wang <[email protected]>
1 parent f0a4017 commit 49b5933

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/zlib.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -527,14 +527,12 @@ function processChunkSync(self, chunk, flushFlag) {
527527
}
528528

529529
self.bytesWritten = inputRead;
530+
_close(self);
530531

531532
if (nread >= kMaxLength) {
532-
_close(self);
533533
throw new ERR_BUFFER_TOO_LARGE();
534534
}
535535

536-
_close(self);
537-
538536
if (nread === 0)
539537
return Buffer.alloc(0);
540538

0 commit comments

Comments
 (0)