Skip to content

Commit d44468d

Browse files
committed
fix(timings): unit index is not assigned sequentially
1 parent 4e0b40d commit d44468d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/cargo/core/compiler/timings/timings.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ let UNIT_COORDS = {};
2222
// Map of unit index to the index it was unlocked by.
2323
let REVERSE_UNIT_DEPS = {};
2424
let REVERSE_UNIT_RMETA_DEPS = {};
25+
let UNIT_BY_INDEX = {};
2526

2627
const MIN_GRAPH_WIDTH = 200;
2728
const MAX_GRAPH_WIDTH = 4096;
@@ -76,13 +77,13 @@ const DEP_LINE_COLOR = getCssColor('--canvas-dep-line');
7677
const DEP_LINE_HIGHLIGHTED_COLOR = getCssColor('--canvas-dep-line-highlighted');
7778
const 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.
320321
function 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

Comments
 (0)