diff --git a/Cargo.toml b/Cargo.toml index 269b4f5..129bf82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ doctest = false [dependencies] unicode-xid = "0.1" -memchr = "2.0" [features] unstable = [] diff --git a/src/lib.rs b/src/lib.rs index 10606fe..de3a2e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,9 +23,6 @@ extern crate proc_macro; -#[cfg(not(feature = "unstable"))] -extern crate memchr; - #[cfg(not(feature = "unstable"))] extern crate unicode_xid; diff --git a/src/stable.rs b/src/stable.rs index 041130c..e3fc477 100644 --- a/src/stable.rs +++ b/src/stable.rs @@ -12,8 +12,6 @@ use std::rc::Rc; use std::str::FromStr; use std::vec; -#[cfg(procmacro2_unstable)] -use memchr; use proc_macro; use unicode_xid::UnicodeXID; use strnom::{Cursor, PResult, skip_whitespace, block_comment, whitespace, word_break}; @@ -264,10 +262,10 @@ impl FileInfo { /// Computes the offsets of each line in the given source string. #[cfg(procmacro2_unstable)] -fn lines_offsets(s: &[u8]) -> Vec { +fn lines_offsets(s: &str) -> Vec { let mut lines = vec![0]; let mut prev = 0; - while let Some(len) = memchr::memchr(b'\n', &s[prev..]) { + while let Some(len) = s[prev..].find('\n') { prev += len + 1; lines.push(prev); } @@ -290,7 +288,7 @@ impl Codemap { } fn add_file(&mut self, name: &str, src: &str) -> Span { - let lines = lines_offsets(src.as_bytes()); + let lines = lines_offsets(src); let lo = self.next_start_pos(); // XXX(nika): Shouild we bother doing a checked cast or checked add here? let span = Span { lo: lo, hi: lo + (src.len() as u32) };