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

Optimize String::Builder#write_byte #4853

merged 1 commit into from Aug 19, 2017


Copy link

IO defines write_byte generically in terms of write(Bytes). Many IO types, like IO::Memory and others, override it for a small performance boost. This was missing in String::Builder.

This snippet:

time = do |io|
  1_000_000.times do |byte|
    io.write_byte((byte % 256).to_u8)
puts - time

used to print 00:00:00.0099520 in my machine, now it prints 00:00:00.0049270

@asterite asterite merged commit 1655935 into master Aug 19, 2017
@asterite asterite deleted the feature/optimize-string-builder-write-byte branch August 19, 2017 16:40
@asterite asterite added this to the Next milestone Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants