@@ -22,6 +22,7 @@ let UNIT_COORDS = {};
2222// Map of unit index to the index it was unlocked by.
2323let REVERSE_UNIT_DEPS = { } ;
2424let REVERSE_UNIT_RMETA_DEPS = { } ;
25+ let UNIT_BY_INDEX = { } ;
2526
2627const MIN_GRAPH_WIDTH = 200 ;
2728const MAX_GRAPH_WIDTH = 4096 ;
@@ -76,13 +77,13 @@ const DEP_LINE_COLOR = getCssColor('--canvas-dep-line');
7677const DEP_LINE_HIGHLIGHTED_COLOR = getCssColor ( '--canvas-dep-line-highlighted' ) ;
7778const CPU_COLOR = getCssColor ( '--canvas-cpu' ) ;
7879
79- for ( let n = 0 ; n < UNIT_DATA . length ; n ++ ) {
80- let unit = UNIT_DATA [ n ] ;
80+ for ( const unit of UNIT_DATA ) {
81+ UNIT_BY_INDEX [ unit . i ] = unit ;
8182 for ( let unblocked of unit . unblocked_units ) {
82- REVERSE_UNIT_DEPS [ unblocked ] = n ;
83+ REVERSE_UNIT_DEPS [ unblocked ] = unit . i ;
8384 }
8485 for ( let unblocked of unit . unblocked_rmeta_units ) {
85- REVERSE_UNIT_RMETA_DEPS [ unblocked ] = n ;
86+ REVERSE_UNIT_RMETA_DEPS [ unblocked ] = unit . i ;
8687 }
8788}
8889
@@ -318,7 +319,7 @@ function get_codegen_section_x(sections) {
318319
319320// Draws lines from the given unit to the units it unlocks.
320321function draw_dep_lines ( ctx , unit_idx , highlighted ) {
321- const unit = UNIT_DATA [ unit_idx ] ;
322+ const unit = UNIT_BY_INDEX [ unit_idx ] ;
322323 const { x, y, sections} = UNIT_COORDS [ unit_idx ] ;
323324 ctx . save ( ) ;
324325 for ( const unblocked of unit . unblocked_units ) {
0 commit comments