Skip to content

Commit 941bedf

Browse files
MCproteinpull[bot]
authored andcommitted
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent a510c5d commit 941bedf

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

‎lib/zlib.js‎

Lines changed: 2 additions & 3 deletions
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
constflushiness=[];
364-
leti=0;
365364
constkFlushFlagList=[Z_NO_FLUSH,Z_BLOCK,Z_PARTIAL_FLUSH,
366365
Z_SYNC_FLUSH,Z_FULL_FLUSH,Z_FINISH];
367-
for(constflushFlagofkFlushFlagList){
368-
flushiness[flushFlag]=i++;
366+
for(leti=0;i<kFlushFlagList.length;i++){
367+
flushiness[kFlushFlagList[i]]=i;
369368
}
370369

371370
functionmaxFlush(a,b){

0 commit comments

Comments
(0)