Skip to content

Commit 8a2ea92

Browse files
committed
perf(semantics): map output ranges in ASCII SQL without scanning it
Character offsets are byte offsets in ASCII text, so the per-character scan now runs only for SQL holding multi-byte characters. This keeps the analysis instruction count within its recorded baseline.
1 parent 23c1099 commit 8a2ea92

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • crates/sqlquack-semantics/src/lineage/_helpers/tracing

‎crates/sqlquack-semantics/src/lineage/_helpers/tracing/statement.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ fn byte_ranges(sql: Option<&str>, spans: Vec<Option<Span>>) -> Vec<Option<Range<
4747
let Some(sql) = sql else {
4848
return vec![None; spans.len()];
4949
};
50+
if sql.is_ascii() {
51+
return spans
52+
.into_iter()
53+
.map(|span| {
54+
let span = span?;
55+
(span.start < span.end && span.end <= sql.len()).then_some(span.start..span.end)
56+
})
57+
.collect();
58+
}
5059
let mut offsets: Vec<usize> = spans
5160
.iter()
5261
.flatten()

0 commit comments

Comments
 (0)