mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-07 11:03:15 +00:00
perf(engine): list a few step names in a missing-reference error (#1941)
Every missing $ref rendered the batch's whole name table into its error, and with onError: continue each such error was kept, so a compact batch cost its name count per failed step. The hint names twelve steps and counts the rest.
This commit is contained in:
1 parent
b9b64a8755
commit
32b658fe71
1 file changed
+8
-2
@@ -156,14 +156,20 @@ impl BatchScope {
|
||||
lookup(result, path).cloned().map_err(|why| fail(format!("{who}'s result has no `{path}`{why}")))
|
||||
}
|
||||
|
||||
/// Most step names a missing-reference error lists.
|
||||
const NAME_HINTS: usize = 12;
|
||||
|
||||
fn known_names(&self) -> String {
|
||||
let mut names: Vec<_> = self.names.iter().collect();
|
||||
names.sort_by_key(|(_, i)| **i);
|
||||
if names.is_empty() {
|
||||
return "no step has an `as` name".into();
|
||||
}
|
||||
let list: Vec<_> = names.iter().map(|(name, i)| format!("\"{name}\" is step {i}")).collect();
|
||||
list.join(", ")
|
||||
// A few of them: the list is built for every missing reference and, with `onError:
|
||||
// continue`, kept for each, so a long table would cost its length per failed step.
|
||||
let list: Vec<_> = names.iter().take(Self::NAME_HINTS).map(|(name, i)| format!("\"{name}\" is step {i}")).collect();
|
||||
let more = names.len().saturating_sub(Self::NAME_HINTS);
|
||||
if more > 0 { format!("{}, {more} more", list.join(", ")) } else { list.join(", ") }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user