Skip to content

perf: eliminate intermediate String allocation in facade log output - #2

Open
BobBinaryBuilder wants to merge 1 commit into
mainfrom
perf/eliminate-tostring-in-facades
Open

perf: eliminate intermediate String allocation in facade log output#2
BobBinaryBuilder wants to merge 1 commit into
mainfrom
perf/eliminate-tostring-in-facades

Conversation

@BobBinaryBuilder

Copy link
Copy Markdown
Collaborator

StdOut, StdErr and File facades were calling msg.to_string() to get a heap-allocated String, then converting it to bytes for write_all, plus a separate write_all for the newline. Replace with writeln!(handle, "{}", msg) which formats directly into the output buffer via Display, avoiding the intermediate allocation entirely.

Syslog is unchanged as CString inherently requires an owned buffer.

Note: This is done with claude code (opus model)

StdOut, StdErr and File facades were calling msg.to_string() to get a
heap-allocated String, then converting it to bytes for write_all, plus
a separate write_all for the newline. Replace with writeln!(handle, "{}", msg)
which formats directly into the output buffer via Display, avoiding
the intermediate allocation entirely.

Syslog is unchanged as CString inherently requires an owned buffer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant