Skip to content

Commit f209a2d

Browse files
committed
progress
1 parent ce0be2c commit f209a2d

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

crates/pgt_statement_splitter/benches/splitter.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use criterion::{Criterion, black_box, criterion_group, criterion_main};
22
use pgt_statement_splitter::split;
33

44
pub fn splitter_benchmark(c: &mut Criterion) {
5-
c.bench_function("large statement", |b| {
6-
let statement = r#"with
5+
let large_statement = r#"with
76
available_tables as (
87
select
98
c.relname as table_name,
@@ -62,18 +61,24 @@ where
6261
6362
"#;
6463

65-
let content = statement.repeat(500);
64+
let large_content = large_statement.repeat(500);
6665

67-
b.iter(|| black_box(split(&content)));
68-
});
66+
c.bench_function(
67+
format!("large statement with length {}", large_content.len()).as_str(),
68+
|b| {
69+
b.iter(|| black_box(split(&large_content)));
70+
},
71+
);
6972

70-
c.bench_function("small statement", |b| {
71-
let statement = r#"select 1 from public.user where id = 1"#;
73+
let small_statement = r#"select 1 from public.user where id = 1"#;
74+
let small_content = small_statement.repeat(500);
7275

73-
let content = statement.repeat(500);
74-
75-
b.iter(|| black_box(split(&content)));
76-
});
76+
c.bench_function(
77+
format!("small statement with length {}", small_content.len()).as_str(),
78+
|b| {
79+
b.iter(|| black_box(split(&small_content)));
80+
},
81+
);
7782
}
7883

7984
criterion_group!(benches, splitter_benchmark);

crates/pgt_workspace/src/workspace/server/document.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ where
155155

156156
if let Ok(ast) = self.parser.ast_db.get_or_cache_ast(&root_id).as_ref() {
157157
// Check if this is a SQL function definition with a body
158-
if let Some(sub_statement) = get_sql_fn_body(ast, &content) {
158+
if let Some(sub_statement) = get_sql_fn_body(ast, content) {
159159
// Add sub-statements to our pending queue
160160
self.pending_sub_statements.push((
161161
root_id.create_child(&sub_statement.body),

0 commit comments

Comments
 (0)