diff --git a/crates/ui-egui/src/editor.rs b/crates/ui-egui/src/editor.rs index d3cab75ea..71fd2a170 100644 --- a/crates/ui-egui/src/editor.rs +++ b/crates/ui-egui/src/editor.rs @@ -375,7 +375,7 @@ pub fn formula_refs(text: &str) -> Vec<(usize, usize, RangeRef, Option, let offset = text.len() - body.len(); let Ok(toks) = gridcraft_engine::formula::lexer::tokenize(body) else { return vec![] }; let mut out: Vec<(usize, usize, RangeRef, Option, usize)> = Vec::new(); - let mut seen: Vec = Vec::new(); + let mut seen: std::collections::HashMap = std::collections::HashMap::new(); let mut i = 0; while i < toks.len() { use gridcraft_engine::formula::lexer::Tok; @@ -407,13 +407,8 @@ pub fn formula_refs(text: &str) -> Vec<(usize, usize, RangeRef, Option, continue; }; let key = body.get(start..end).unwrap_or("").replace('$', "").to_ascii_uppercase(); - let idx = match seen.iter().position(|k| *k == key) { - Some(k) => k, - None => { - seen.push(key); - seen.len() - 1 - } - }; + let next = seen.len(); + let idx = *seen.entry(key).or_insert(next); out.push((start + offset, end + offset, range, sheet, idx % REF_COLOR_COUNT)); continue; } diff --git a/crates/ui-egui/src/grid/quadrant.rs b/crates/ui-egui/src/grid/quadrant.rs index 0469c345f..7461c2204 100644 --- a/crates/ui-egui/src/grid/quadrant.rs +++ b/crates/ui-egui/src/grid/quadrant.rs @@ -278,6 +278,9 @@ fn paint_cell_decorations(q: &QuadrantPaint<'_>, c: CellRef, rect: Rect, lk: &Lo false } +/// Most repeats of a fill character laid out in one cell. +const MAX_FILL_REPEATS: usize = 8192; + fn paint_data_bar(p: &egui::Painter, rect: Rect, frac: f32, rgb: [u8; 3], gradient: bool) { let bar = Rect::from_min_size(pos2(rect.left() + 2.0, rect.top() + 2.0), vec2((rect.width() - 4.0) * frac, rect.height() - 4.0)); let col = theme::color32(rgb); @@ -432,7 +435,8 @@ fn paint_cell(q: &QuadrantPaint<'_>, painted: &(CellRef, Rect, Look, Option