MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / compute_cell_width

Function compute_cell_width

src/display.rs:207–219  ·  view source on GitHub ↗

Compute cell width from the widest node-kind entry, capped at `MAX_CELL_WIDTH`.

(sorted_kinds: &[(&String, &u64)])

Source from the content-addressed store, hash-verified

205
206/// Compute cell width from the widest node-kind entry, capped at `MAX_CELL_WIDTH`.
207fn compute_cell_width(sorted_kinds: &[(&String, &u64)]) -> usize {
208 let max_kind_len = sorted_kinds
209 .iter()
210 .map(|(k, _)| k.len())
211 .max()
212 .unwrap_or(10);
213 let max_count_len = sorted_kinds
214 .iter()
215 .map(|(_, c)| format_number(**c).len())
216 .max()
217 .unwrap_or(5);
218 (max_kind_len + max_count_len + 3).clamp(22, MAX_CELL_WIDTH)
219}
220
221/// Print the top title row: version (left) + country flags (right).
222/// Returns a shuffled copy of `flags` using xorshift64 seeded from time + PID.

Callers 2

print_status_headerFunction · 0.85
print_status_tableFunction · 0.85

Calls 1

format_numberFunction · 0.70

Tested by

no test coverage detected