Skip to content

perf: avoid using write! macro with single str#228

Merged
epage merged 1 commit intorust-cli:mainfrom
DaniPopes:avoid-write-macro-str
Nov 1, 2024
Merged

perf: avoid using write! macro with single str#228
epage merged 1 commit intorust-cli:mainfrom
DaniPopes:avoid-write-macro-str

Conversation

@DaniPopes
Copy link
Copy Markdown
Contributor

@DaniPopes DaniPopes commented Nov 1, 2024

A known issue with write! is that it's slower and generates more code than direct calls to write_str, unfortunately even in the simple case of "{str}". See rust-lang/rust#76490.

I've verified with Godbolt that it is still the case: https://godbolt.org/z/sq3M8xWfo

@DaniPopes DaniPopes force-pushed the avoid-write-macro-str branch from 034dd12 to 4c4eaf9 Compare November 1, 2024 13:06
@DaniPopes DaniPopes changed the title perf(anstyle): avoid using write! macro with single str perf: avoid using write! macro with single str Nov 1, 2024
@DaniPopes DaniPopes force-pushed the avoid-write-macro-str branch from 4c4eaf9 to fb843c5 Compare November 1, 2024 13:06
@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 11629840392

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.06%) to 51.742%

Totals Coverage Status
Change from base Build 11506573894: -0.06%
Covered Lines: 1218
Relevant Lines: 2354

💛 - Coveralls

@epage epage merged commit 13e008a into rust-cli:main Nov 1, 2024
@DaniPopes DaniPopes deleted the avoid-write-macro-str branch November 1, 2024 14:11
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.

3 participants