Skip to content

Commit 89e6a81

Browse files
author
Jorge Aparicio
committed
libregex: remove unnecessary as_slice calls
1 parent 0ea3134 commit 89e6a81

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/libregex/parse.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,11 @@ impl<'a> Parser<'a> {
523523

524524
// Parse the min and max values from the regex.
525525
let (mut min, mut max): (uint, Option<uint>);
526-
if !inner.as_slice().contains(",") {
526+
if !inner.contains(",") {
527527
min = try!(self.parse_uint(inner.as_slice()));
528528
max = Some(min);
529529
} else {
530-
let pieces: Vec<&str> = inner.as_slice().splitn(1, ',').collect();
530+
let pieces: Vec<&str> = inner.splitn(1, ',').collect();
531531
let (smin, smax) = (pieces[0], pieces[1]);
532532
if smin.len() == 0 {
533533
return self.err("Max repetitions cannot be specified \
@@ -751,7 +751,7 @@ impl<'a> Parser<'a> {
751751
return self.err("Capture names must have at least 1 character.")
752752
}
753753
let name = self.slice(self.chari, closer);
754-
if !name.as_slice().chars().all(is_valid_cap) {
754+
if !name.chars().all(is_valid_cap) {
755755
return self.err(
756756
"Capture names can only have underscores, letters and digits.")
757757
}

src/libregex/test/tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,13 @@ macro_rules! mat(
156156
};
157157
// The test set sometimes leave out capture groups, so truncate
158158
// actual capture groups to match test set.
159-
let (sexpect, mut sgot) = (expected.as_slice(), got.as_slice());
160-
if sgot.len() > sexpect.len() {
161-
sgot = sgot[0..sexpect.len()]
159+
let mut sgot = got.as_slice();
160+
if sgot.len() > expected.len() {
161+
sgot = sgot[0..expected.len()]
162162
}
163-
if sexpect != sgot {
163+
if expected != sgot {
164164
panic!("For RE '{}' against '{}', expected '{}' but got '{}'",
165-
$re, text, sexpect, sgot);
165+
$re, text, expected, sgot);
166166
}
167167
}
168168
);

src/libregex/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'r, 't> Nfa<'r, 't> {
147147
// jump ahead quickly. If it can't be found, then we can bail
148148
// out early.
149149
if self.prog.prefix.len() > 0 && clist.size == 0 {
150-
let needle = self.prog.prefix.as_slice().as_bytes();
150+
let needle = self.prog.prefix.as_bytes();
151151
let haystack = self.input.as_bytes()[self.ic..];
152152
match find_prefix(needle, haystack) {
153153
None => break,

0 commit comments

Comments
 (0)