Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 941bedf

Browse files
MCproteinpull[bot]
authored andcommittedAug 14, 2024
lib: avoid for of loop and remove unnecessary variable in zlib
removed the unnecessary declaration of 'i' in the _final method scope and changed the for of loop to a for loop Refs: https://github.com/nodejs/node/blob/main/doc/contributing/primordials.md#unsafe-array-iteration PR-URL: #54258 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent a510c5d commit 941bedf

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎lib/zlib.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,10 @@ ZlibBase.prototype._final = function(callback) {
361361
// Z_NO_FLUSH (< Z_TREES) < Z_BLOCK < Z_PARTIAL_FLUSH <
362362
// Z_SYNC_FLUSH < Z_FULL_FLUSH < Z_FINISH
363363
const flushiness = [];
364-
let i = 0;
365364
const kFlushFlagList = [Z_NO_FLUSH, Z_BLOCK, Z_PARTIAL_FLUSH,
366365
Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH];
367-
for (const flushFlag of kFlushFlagList) {
368-
flushiness[flushFlag] = i++;
366+
for (let i = 0; i < kFlushFlagList.length; i++) {
367+
flushiness[kFlushFlagList[i]] = i;
369368
}
370369

371370
function maxFlush(a, b) {

0 commit comments

Comments
 (0)
Please sign in to comment.