Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace format! with print! when String construction is unnecessary #12243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Integral-Tech
Copy link

@Integral-Tech Integral-Tech commented Dec 13, 2024

  • Although format! macro is very powerful, it introduces overhead of memory allocation on the heap compared to &str. Therefore, when format! macro is unnecessary, we should avoid using it.

@Integral-Tech Integral-Tech changed the title refactor: replace format! with concat! or format_args! when unnecessary refactor: replace format! with concat! or print! when unnecessary Dec 14, 2024
Copy link
Contributor

@TornaxO7 TornaxO7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, this isn't really needed.
Yes, it's true, that format uses the heap, but performance wise it's neglectable.
I would prefer readability over "micro-performance-improvements" in this case.

helix-loader/build.rs Outdated Show resolved Hide resolved
@Integral-Tech Integral-Tech changed the title refactor: replace format! with concat! or print! when unnecessary refactor: replace format! with print! when String construction is unnecessary Dec 14, 2024
@Integral-Tech
Copy link
Author

@TornaxO7 I have just reverted the changes in helix-loader/build.rs.

@TornaxO7
Copy link
Contributor

Eh, I'm not a maintainer, so you needn't see my review as "mandatory". Those are just my two cents :>

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.

2 participants