Refactor regex compilation and use is_some_and

This commit introduces several improvements:

- Pre-compiles regular expressions in `ast/tester.rs` to avoid redundant
  compilation, improving performance.
- Replaces `.extension().map_or(false, |ext| ext == "myc")` with the
  more concise and readable `.extension().is_some_and(|ext| ext ==
  "myc")`.
- Simplifies upvalue capture logic by using `.or_default()` instead of
  `.or_insert_with(HashSet::new)`.
- Adds a `Default` implementation for `TracingObserver`.
- Optimizes string literal parsing in `highlight_myc` to correctly
  handle escape sequences.
- Uses `saturating_sub` for bracket depth to prevent underflow.
This commit is contained in:
Michael Schimmel
2026-02-18 01:24:28 +01:00
parent 1d1b54ed16
commit 9b16bc47be
4 changed files with 34 additions and 27 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ impl UpvalueAnalyzer {
// Captured from an outer scope!
if let Some(lambda_id) = &current_lambda {
capture_map.entry(decl_id.clone())
.or_insert_with(HashSet::new)
.or_default()
.insert(lambda_id.clone());
}
}