extract truncation helpers, fix clippy warnings, dedup batching loop

Add util::truncate() and util::first_n_chars() to replace 16 call
sites doing the same floor_char_boundary or chars().take().collect()
patterns. Deduplicate the batching loop in consolidate.rs (4 copies
→ 1 loop over an array). Fix all clippy warnings: redundant closures,
needless borrows, collapsible if, unnecessary cast, manual strip_prefix.

Net: -44 lines across 16 files.
This commit is contained in:
ProofOfConcept 2026-03-08 21:13:02 -04:00
parent e24dee6bdf
commit 52523403c5
16 changed files with 85 additions and 129 deletions

View file

@ -404,13 +404,13 @@ fn execute_parsed(
has_sort = true;
let asc = *ascending;
results.sort_by(|a, b| {
let va = a.fields.get(field).and_then(|v| as_num(v));
let vb = b.fields.get(field).and_then(|v| as_num(v));
let va = a.fields.get(field).and_then(as_num);
let vb = b.fields.get(field).and_then(as_num);
let ord = match (va, vb) {
(Some(a), Some(b)) => a.total_cmp(&b),
_ => {
let sa = a.fields.get(field).map(|v| as_str(v)).unwrap_or_default();
let sb = b.fields.get(field).map(|v| as_str(v)).unwrap_or_default();
let sa = a.fields.get(field).map(as_str).unwrap_or_default();
let sb = b.fields.get(field).map(as_str).unwrap_or_default();
sa.cmp(&sb)
}
};