-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Memchr in std #30381
Memchr in std #30381
Conversation
@@ -0,0 +1,339 @@ | |||
/* Initial implementation taken from Andrew Gallant's rust-memchr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a real copyright header, see other files.
If you put in burntsushi's name, I want to be credited too -- the pure rust memchr impls are mine. bluss is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the rust copyright header, as well as rust-memchrs license header.
@bluss I'd be glad to put your name in as well, what should I put in? It's not in the rust-memchr copyright notice.
I think this is exciting, should be a good perf boost to stdout when writing binary data. |
You can write in (C) bluss or another way to indicate authorship. We should resolve the license question and skip the separate license notice I think. |
@nicokoch Do you agree with dual-licensing your contributions to @BurntSushi Do you agree with dual-licensing your contributions to I myself agree with dual licensing my contributions to rust-memchr 😄. Those are all three authors according to the git history. |
Exciting, my first mini contribution to rust! No problem on my end, go ahead and include it. |
☑️ great, then the little licensing question should be almost cleared, I have no doubt @BurntSushi will be on board as soon as he sees it. |
☑️ relicensing done, well done team ❤️ |
e49137c
to
40900af
Compare
I've update the license stuff, memchr.rs now includes the Rust license header on top and a comment below which indicates the file initially comes from rust-memchr with an copyright attribution for the three contributers. |
// Copyright 2015 Andrew Gallant, bluss and Nicolas Koch | ||
|
||
|
||
extern crate libc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed (libc is already imported in lib.rs)
// libc memchr | ||
#[cfg(any(not(target_os = "windows"), | ||
not(any(target_pointer_width = "32", | ||
target_pointer_width = "64"))))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probably safe to say that if we're porting to a platform which doesn't have 32 or 64-bit pointers this function will be the least of our worries. For now could these clauses in the cfg
annotations just be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(ping on removing these cfgs)
I've update the commit. I also added a PR to libc that adds In the libc PR I also add |
Also yeah updating the submodule is fine, should be fine to do as soon as the libc PR lands. |
I've updated the submodule and the new libc binding of |
@Manishearth I've moved the libc import to the functions that use it |
From travis log, the doc examples need updating (or ignoring)
|
I've added |
Thanks for working on this! |
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
These new functions are private to If they are to become public, I’d prefer to have a more descriptive name, similar to how |
Yep they are an implementation detail. The relnotes-worthy thing is the performance improvements. We'll probably expand the use of these functions soon. |
relnotes related: Improve throughput for LineWriter (and thus default stdout). |
Use the fallback impl for memrchr on non-linux The memrchr code was never used(!). This brings the memrchr improvements to non-linux platforms (LineWriter / buffered stdout benefits). Previous PR #30381
This PR adds
memchr
andmemrchr
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