You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes it's necessary to search for the first occurrence that is not a particular byte (the most obvious example is checking if a buffer is all NUL-bytes and returning the first non-NUL byte). For instance, the Linux kernel has a memchr_inv function for this purpose.
The usecase I have at the moment is that I'm writing a C API for libpathrs that I would like to design to mirror a Linux kernel API, and memchr_inv is needed to check whether a passed buffer is zeroed after a point. I have hand-rolled memchr_inv but I suspect it is far less efficient than something that this crate could provide.
(I guess memchr already handles this, but it's probably worth mentioning that the buffer is probably not going to be 4-byte or 8-byte aligned because offset from where we have to check the buffer could be any value and so the slice could start at any offset.)
Yeah, I think what I wrote in #157 still applies. I do want to add things like this (and stuff in #157). And one way of avoiding the compile time hit is to make them opt-in features, particularly since they are somewhat niche needs. I think the bigger problem is review and maintenance bandwidth.
Sometimes it's necessary to search for the first occurrence that is not a particular byte (the most obvious example is checking if a buffer is all NUL-bytes and returning the first non-NUL byte). For instance, the Linux kernel has a
memchr_inv
function for this purpose.The usecase I have at the moment is that I'm writing a C API for libpathrs that I would like to design to mirror a Linux kernel API, and
memchr_inv
is needed to check whether a passed buffer is zeroed after a point. I have hand-rolledmemchr_inv
but I suspect it is far less efficient than something that this crate could provide.(I guess
memchr
already handles this, but it's probably worth mentioning that the buffer is probably not going to be 4-byte or 8-byte aligned because offset from where we have to check the buffer could be any value and so the slice could start at any offset.)I guess this can be seen as a duplicate of #157, but with a far more restricted scope (just
!=
as opposed to all comparison operations). But I guess the other option would be to just adapt https://github.com/BurntSushi/bstr/blob/e223ec63cab2de544625b8946e372e6d50ab53d2/src/ascii.rs as suggested in that thread...The text was updated successfully, but these errors were encountered: