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

Use memrchr or similar in LineWriter::write #30076

Closed
bluss opened this issue Nov 26, 2015 · 1 comment
Closed

Use memrchr or similar in LineWriter::write #30076

bluss opened this issue Nov 26, 2015 · 1 comment

Comments

@bluss
Copy link
Member

bluss commented Nov 26, 2015

The LineWriter (used by stdout) searches for a newline in each .write() call. As compiled today, this byte search compiles to a byte-by-byte loop. This is a very hot loop, and unnecessarily so if you output data that's not line delimited. Using memchr or equivalent would improve this.

@bluss bluss changed the title Use memchr or similar in LineWriter::write Use memrchr or similar in LineWriter::write Dec 2, 2015
@bluss
Copy link
Member Author

bluss commented Dec 2, 2015

Of course memrchr, I did in fact miss the position vs rposition difference on first reading.

@fhahn fhahn mentioned this issue Dec 14, 2015
bors added a commit that referenced this issue Dec 19, 2015
This PR adds `memchr`and `memrchr` based on @BurntSushi 's rust-memchr crate to libstd (as discussed in #30151).

I've update some places in libstd to use memchr/memrchr, but I am not sure if there are other places where it could be used as well.

ref #30076
@bors bors closed this as completed in de3e843 Dec 19, 2015
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

No branches or pull requests

1 participant