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

Add String overloads for ljust, rjust and center that take an IO #8923

Merged
merged 2 commits into from
Mar 21, 2020

Conversation

asterite
Copy link
Member

Useful to avoid memory allocations, as always.

In particular we could use it in the new Log module to avoid memory allocations at all when logging stuff: https://github.com/crystal-lang/crystal/pull/8847/files#r395989420

@asterite asterite added this to the 0.34.0 milestone Mar 21, 2020
@asterite asterite merged commit 2dc1ccc into master Mar 21, 2020
@asterite asterite mentioned this pull request Mar 21, 2020
@asterite asterite deleted the feature/just-io branch March 21, 2020 18:03
@@ -2578,3 +2599,9 @@ describe "String" do
end
end
end

private def with_io_memory
Copy link
Member

Choose a reason for hiding this comment

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

Why did you not just use String.build instead of this helper?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oooh... it's a long time since I programmed in Crystal, I forgot this already 😅

Copy link
Member

Choose a reason for hiding this comment

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

It's my bad, I didn't check the specs well enough!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants