Skip to content

Commit b79aeab

Browse files
MCproteintargos
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 <daeyeon.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 7e25fab commit b79aeab

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎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)