libregex: remove unnecessary as_slice
calls
This commit is contained in:
parent
0ea31348d9
commit
89e6a81ef9
@ -523,11 +523,11 @@ impl<'a> Parser<'a> {
|
||||
|
||||
// Parse the min and max values from the regex.
|
||||
let (mut min, mut max): (uint, Option<uint>);
|
||||
if !inner.as_slice().contains(",") {
|
||||
if !inner.contains(",") {
|
||||
min = try!(self.parse_uint(inner.as_slice()));
|
||||
max = Some(min);
|
||||
} else {
|
||||
let pieces: Vec<&str> = inner.as_slice().splitn(1, ',').collect();
|
||||
let pieces: Vec<&str> = inner.splitn(1, ',').collect();
|
||||
let (smin, smax) = (pieces[0], pieces[1]);
|
||||
if smin.len() == 0 {
|
||||
return self.err("Max repetitions cannot be specified \
|
||||
@ -751,7 +751,7 @@ impl<'a> Parser<'a> {
|
||||
return self.err("Capture names must have at least 1 character.")
|
||||
}
|
||||
let name = self.slice(self.chari, closer);
|
||||
if !name.as_slice().chars().all(is_valid_cap) {
|
||||
if !name.chars().all(is_valid_cap) {
|
||||
return self.err(
|
||||
"Capture names can only have underscores, letters and digits.")
|
||||
}
|
||||
|
@ -156,13 +156,13 @@ macro_rules! mat(
|
||||
};
|
||||
// The test set sometimes leave out capture groups, so truncate
|
||||
// actual capture groups to match test set.
|
||||
let (sexpect, mut sgot) = (expected.as_slice(), got.as_slice());
|
||||
if sgot.len() > sexpect.len() {
|
||||
sgot = sgot[0..sexpect.len()]
|
||||
let mut sgot = got.as_slice();
|
||||
if sgot.len() > expected.len() {
|
||||
sgot = sgot[0..expected.len()]
|
||||
}
|
||||
if sexpect != sgot {
|
||||
if expected != sgot {
|
||||
panic!("For RE '{}' against '{}', expected '{}' but got '{}'",
|
||||
$re, text, sexpect, sgot);
|
||||
$re, text, expected, sgot);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -147,7 +147,7 @@ impl<'r, 't> Nfa<'r, 't> {
|
||||
// jump ahead quickly. If it can't be found, then we can bail
|
||||
// out early.
|
||||
if self.prog.prefix.len() > 0 && clist.size == 0 {
|
||||
let needle = self.prog.prefix.as_slice().as_bytes();
|
||||
let needle = self.prog.prefix.as_bytes();
|
||||
let haystack = self.input.as_bytes()[self.ic..];
|
||||
match find_prefix(needle, haystack) {
|
||||
None => break,
|
||||
|
Loading…
x
Reference in New Issue
Block a user