@@ -49,15 +49,12 @@ function visitChildren(node, c) {
49
49
}
50
50
return false ;
51
51
}
52
- for ( const key in node ) {
52
+ for ( const child of Object . values ( node ) ) {
53
53
// Check for a child.
54
- if ( Object . prototype . hasOwnProperty . call ( node , key ) ) {
55
- const child = node [ key ] ;
56
- if ( ! maybeChild ( child ) ) {
57
- // Check for an array of children.
58
- if ( Array . isArray ( child ) ) {
59
- child . forEach ( maybeChild ) ;
60
- }
54
+ if ( ! maybeChild ( child ) ) {
55
+ // Check for an array of children.
56
+ if ( Array . isArray ( child ) ) {
57
+ child . forEach ( maybeChild ) ;
61
58
}
62
59
}
63
60
}
@@ -429,14 +426,11 @@ function runJSDCE(ast, aggressive) {
429
426
assert ( scopes . length === 0 ) ;
430
427
431
428
const names = { } ;
432
- for ( const name in scope ) {
433
- if ( Object . prototype . hasOwnProperty . call ( scope , name ) ) {
434
- const data = scope [ name ] ;
435
- if ( data . def && ! data . use ) {
436
- assert ( ! data . param ) ; // can't be
437
- // this is eliminateable!
438
- names [ name ] = 0 ;
439
- }
429
+ for ( const [ name , data ] of Object . entries ( scope ) ) {
430
+ if ( data . def && ! data . use ) {
431
+ assert ( ! data . param ) ; // can't be
432
+ // this is eliminateable!
433
+ names [ name ] = 0 ;
440
434
}
441
435
}
442
436
cleanUp ( ast , names ) ;
@@ -797,26 +791,24 @@ function emitDCEGraph(ast) {
797
791
return 'emcc$' + what + '$' + name ;
798
792
}
799
793
const infos = { } ; // the graph name of the item => info for it
800
- imports . forEach ( ( import_ ) => {
794
+ for ( const import_ of imports ) {
801
795
const name = getGraphName ( import_ , 'import' ) ;
802
796
const info = infos [ name ] = {
803
797
name : name ,
804
798
import : [ 'env' , import_ ] ,
805
799
reaches : { } ,
806
800
} ;
807
- if ( Object . prototype . hasOwnProperty . call ( nameToGraphName , import_ ) ) {
801
+ if ( nameToGraphName . hasOwnProperty ( import_ ) ) {
808
802
info . reaches [ nameToGraphName [ import_ ] ] = 1 ;
809
803
} // otherwise, it's a number, ignore
810
- } ) ;
811
- for ( const e in exportNameToGraphName ) {
812
- if ( Object . prototype . hasOwnProperty . call ( exportNameToGraphName , e ) ) {
813
- const name = exportNameToGraphName [ e ] ;
814
- infos [ name ] = {
815
- name : name ,
816
- export : e ,
817
- reaches : { } ,
818
- } ;
819
- }
804
+ }
805
+ for ( const [ e , name ] of Object . entries ( exportNameToGraphName ) ) {
806
+ const name = exportNameToGraphName [ e ] ;
807
+ infos [ name ] = {
808
+ name : name ,
809
+ export : e ,
810
+ reaches : { } ,
811
+ } ;
820
812
}
821
813
// a function that handles a node we visit, in either a defun or
822
814
// the toplevel scope (in which case the second param is not provided)
@@ -826,12 +818,12 @@ function emitDCEGraph(ast) {
826
818
let reached ;
827
819
if ( node . type === 'Identifier' ) {
828
820
const name = node . name ;
829
- if ( Object . prototype . hasOwnProperty . call ( nameToGraphName , name ) ) {
821
+ if ( nameToGraphName . hasOwnProperty ( name ) ) {
830
822
reached = nameToGraphName [ name ] ;
831
823
}
832
824
} else if ( isModuleUse ( node ) ) {
833
825
const name = getAsmOrModuleUseName ( node ) ;
834
- if ( Object . prototype . hasOwnProperty . call ( modulePropertyToGraphName , name ) ) {
826
+ if ( modulePropertyToGraphName . hasOwnProperty ( name ) ) {
835
827
reached = modulePropertyToGraphName [ name ] ;
836
828
}
837
829
} else if ( isStaticDynCall ( node ) ) {
@@ -842,7 +834,7 @@ function emitDCEGraph(ast) {
842
834
} else if ( isAsmUse ( node ) ) {
843
835
// any remaining asm uses are always rooted in any case
844
836
const name = getAsmOrModuleUseName ( node ) ;
845
- if ( Object . prototype . hasOwnProperty . call ( exportNameToGraphName , name ) ) {
837
+ if ( exportNameToGraphName . hasOwnProperty ( name ) ) {
846
838
infos [ exportNameToGraphName [ name ] ] . root = true ;
847
839
}
848
840
return ;
@@ -885,10 +877,8 @@ function emitDCEGraph(ast) {
885
877
// sort for determinism
886
878
function sortedNamesFromMap ( map ) {
887
879
const names = [ ] ;
888
- for ( const name in map ) {
889
- if ( Object . prototype . hasOwnProperty . call ( map , name ) ) {
890
- names . push ( name ) ;
891
- }
880
+ for ( const name of Object . keys ( map ) ) {
881
+ names . push ( name ) ;
892
882
}
893
883
names . sort ( ) ;
894
884
return names ;
0 commit comments