This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit f8069ba
committed
Auto merge of rust-lang#121001 - nyurik:optimize-core-fmt, r=<try>
perf: improve write_fmt to handle simple strings
Per `@dtolnay` suggestion in serde-rs/serde#2697 (comment) - attempt to speed up performance in the cases of a simple string format without arguments:
```rust
write!(f, "text") -> f.write_str("text")
```
```diff
+ #[inline]
pub fn write_fmt(&mut self, f: fmt::Arguments) -> fmt::Result {
+ if let Some(s) = f.as_str() {
+ self.buf.write_str(s)
+ } else {
write(self.buf, f)
+ }
}
```
* Hopefully it will improve the simple case for the rust-lang#99012
* Another related (original?) issues rust-lang#10761
* Previous similar attempt to fix it by by `@Kobzol` rust-lang#100700
CC: `@m-ou-se` as probably the biggest expert in everything `format!`2 files changed
+28
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
211 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
212 | 220 | | |
213 | 221 | | |
214 | 222 | | |
| |||
430 | 438 | | |
431 | 439 | | |
432 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
433 | 450 | | |
434 | 451 | | |
435 | 452 | | |
| |||
1582 | 1599 | | |
1583 | 1600 | | |
1584 | 1601 | | |
| 1602 | + | |
1585 | 1603 | | |
1586 | | - | |
| 1604 | + | |
1587 | 1605 | | |
1588 | 1606 | | |
1589 | 1607 | | |
| |||
2272 | 2290 | | |
2273 | 2291 | | |
2274 | 2292 | | |
| 2293 | + | |
2275 | 2294 | | |
2276 | | - | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
2277 | 2300 | | |
2278 | 2301 | | |
2279 | 2302 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
| |||
0 commit comments