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

Drop memchr dependency #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ repository = "https://github.com/bbqsrc/core2"
categories = ["no-std"]

[dependencies]
memchr = { version = "2", default-features = false }

[features]
default = ["std"]
Expand Down
6 changes: 3 additions & 3 deletions src/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ impl<'a, W: Write, const S: usize> Write for LineWriterShim<'a, W, S> {
/// writer, it will also flush the existing buffer if it ends with a
/// newline, even if the incoming data does not contain any newlines.
fn write(&mut self, buf: &[u8]) -> Result<usize> {
let newline_idx = match memchr::memrchr(b'\n', buf) {
let newline_idx = match buf.iter().rev().position(|b| *b == b'\n') {
// If there are no new newlines (that is, if this write is less than
// one line), just do a regular buffered write (which may flush if
// we exceed the inner buffer's size)
Expand Down Expand Up @@ -866,7 +866,7 @@ impl<'a, W: Write, const S: usize> Write for LineWriterShim<'a, W, S> {
} else {
let scan_area = &buf[flushed..];
let scan_area = &scan_area[..self.buffer.capacity()];
match memchr::memrchr(b'\n', scan_area) {
match scan_area.iter().rev().position(|b| *b == b'\n') {
Some(newline_idx) => &scan_area[..newline_idx + 1],
None => scan_area,
}
Expand All @@ -889,7 +889,7 @@ impl<'a, W: Write, const S: usize> Write for LineWriterShim<'a, W, S> {
/// writer, it will also flush the existing buffer if it contains any
/// newlines, even if the incoming data does not contain any newlines.
fn write_all(&mut self, buf: &[u8]) -> Result<()> {
match memchr::memrchr(b'\n', buf) {
match buf.iter().rev().position(|b| *b == b'\n') {
// If there are no new newlines (that is, if this write is less than
// one line), just do a regular buffered write (which may flush if
// we exceed the inner buffer's size)
Expand Down
Loading