Skip to content

Commit 049fb83

Browse files
andygroveclaude
andcommitted
minor: use format!() for placeholder string construction
Replace `String::from("?") + &s` and `String::from("$") + &value` with `format!()` macro calls. The format macro calculates required capacity upfront and allocates once, avoiding potential reallocation when the appended string exceeds the initial small capacity. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6550ec8 commit 049fb83

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/tokenizer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ impl<'a> Tokenizer<'a> {
17551755
'?' => {
17561756
chars.next();
17571757
let s = peeking_take_while(chars, |ch| ch.is_numeric());
1758-
Ok(Some(Token::Placeholder(String::from("?") + &s)))
1758+
Ok(Some(Token::Placeholder(format!("?{s}"))))
17591759
}
17601760

17611761
// identifier or keyword
@@ -1904,7 +1904,7 @@ impl<'a> Tokenizer<'a> {
19041904
}
19051905
}
19061906
} else {
1907-
return Ok(Token::Placeholder(String::from("$") + &value));
1907+
return Ok(Token::Placeholder(format!("${value}")));
19081908
}
19091909
}
19101910

0 commit comments

Comments
 (0)