You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fa0e7b0
Browse filesBrowse the repository at this point in the historyBrowse files
⚡ Bolt: avoid temporary allocations in format string generation
Replaced `push_str(&format!(...))` with `let _ = write!(buffer, ...)` via `std::fmt::Write` in string generation loops in stdlib `web.rs`, `xml.rs` and `yaml.rs`.
This prevents creating temporary strings that get immediately dropped and improves performance by writing directly to the target buffer.
Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com>
Copy file name to clipboardExpand all lines: .jules/bolt.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,3 +14,6 @@
14
14
## 2024-05-24 - Avoid `push_str(&format!(...))` in loops
15
15
**Learning:** Using `push_str(&format!(...))` inside loops creates unnecessary temporary String allocations because `format!` allocates a new `String` which is then appended and immediately dropped.
16
16
**Action:** Use `std::fmt::Write` and the `write!` macro directly onto the target string buffer instead.
17
+
## 2025-02-12 - String allocation optimization
18
+
**Learning:** In heavily used loops, especially for rendering or stringifying tasks, `push_str(&format!(...))` allocates temporary strings unnecessarily. Replacing it with `write!` directly onto the mutable `String` buffer (using `std::fmt::Write`) skips the intermediate allocations and improves performance significantly.
19
+
**Action:** Use `std::fmt::Write` and the `write!` macro instead of `push_str(&format!(...))` when generating strings in loops to prevent temporary allocations and improve performance.
0 commit comments