Skip to content

Commit

Permalink
lib: avoid for of loop and remove unnecessary variable in zlib
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
MCprotein authored and targos committed Aug 14, 2024
1 parent 6f4b5d9 commit 09f411e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,10 @@ ZlibBase.prototype._final = function(callback) {
// Z_NO_FLUSH (< Z_TREES) < Z_BLOCK < Z_PARTIAL_FLUSH <
// Z_SYNC_FLUSH < Z_FULL_FLUSH < Z_FINISH
const flushiness = [];
let i = 0;
const kFlushFlagList = [Z_NO_FLUSH, Z_BLOCK, Z_PARTIAL_FLUSH,
Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH];
for (const flushFlag of kFlushFlagList) {
flushiness[flushFlag] = i++;
for (let i = 0; i < kFlushFlagList.length; i++) {
flushiness[kFlushFlagList[i]] = i;
}

function maxFlush(a, b) {
Expand Down

0 comments on commit 09f411e

Please sign in to comment.