Commit 45bf510
minor: use format!() and avoid unnecessary string allocations
- Replace `String::from("?") + &s` with `format!("?{s}")` in tokenizer
- Replace `String::from("$") + &value` with `format!("${value}")` in tokenizer
- Replace `tok.to_string() + &ident.value` with `format!("{tok}{}", ident.value)` in parser
- Replace `" ".to_string() + &...` with `format!(" {}", ...)` in AST display
- Replace `String::from("")` with `String::new()`
- Replace `.to_string()` + `.clear()` with `std::mem::take()` to avoid cloning
The format!() macro calculates required capacity upfront and allocates once,
avoiding potential reallocation. std::mem::take() moves the String instead
of cloning it.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent 6550ec8 commit 45bf510
3 files changed
Lines changed: 8 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4921 | 4921 | | |
4922 | 4922 | | |
4923 | 4923 | | |
4924 | | - | |
| 4924 | + | |
4925 | 4925 | | |
4926 | | - | |
| 4926 | + | |
4927 | 4927 | | |
4928 | 4928 | | |
4929 | 4929 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11146 | 11146 | | |
11147 | 11147 | | |
11148 | 11148 | | |
11149 | | - | |
| 11149 | + | |
11150 | 11150 | | |
11151 | 11151 | | |
11152 | 11152 | | |
11153 | | - | |
11154 | | - | |
| 11153 | + | |
11155 | 11154 | | |
11156 | 11155 | | |
11157 | | - | |
11158 | | - | |
| 11156 | + | |
11159 | 11157 | | |
11160 | 11158 | | |
11161 | 11159 | | |
| |||
11280 | 11278 | | |
11281 | 11279 | | |
11282 | 11280 | | |
11283 | | - | |
| 11281 | + | |
11284 | 11282 | | |
11285 | 11283 | | |
11286 | 11284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1755 | 1755 | | |
1756 | 1756 | | |
1757 | 1757 | | |
1758 | | - | |
| 1758 | + | |
1759 | 1759 | | |
1760 | 1760 | | |
1761 | 1761 | | |
| |||
1904 | 1904 | | |
1905 | 1905 | | |
1906 | 1906 | | |
1907 | | - | |
| 1907 | + | |
1908 | 1908 | | |
1909 | 1909 | | |
1910 | 1910 | | |
| |||
0 commit comments