diff options
Diffstat (limited to 'src/libregex/vm.rs')
| -rw-r--r-- | src/libregex/vm.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libregex/vm.rs b/src/libregex/vm.rs index 990d5a159f6..72e0e559c80 100644 --- a/src/libregex/vm.rs +++ b/src/libregex/vm.rs @@ -38,6 +38,7 @@ pub use self::StepState::*; use std::cmp; use std::mem; +use std::iter::repeat; use std::slice::SliceExt; use compile::{ Program, @@ -121,7 +122,7 @@ impl<'r, 't> Nfa<'r, 't> { let mut clist = &mut Threads::new(self.which, ninsts, ncaps); let mut nlist = &mut Threads::new(self.which, ninsts, ncaps); - let mut groups = Vec::from_elem(ncaps * 2, None); + let mut groups: Vec<_> = repeat(None).take(ncaps * 2).collect(); // Determine if the expression starts with a '^' so we can avoid // simulating .*? @@ -227,8 +228,7 @@ impl<'r, 't> Nfa<'r, 't> { let negate = flags & FLAG_NEGATED > 0; let casei = flags & FLAG_NOCASE > 0; let found = ranges.as_slice(); - let found = found.binary_search(|&rc| class_cmp(casei, c, rc)) - .found().is_some(); + let found = found.binary_search_by(|&rc| class_cmp(casei, c, rc)).is_ok(); if found ^ negate { self.add(nlist, pc+1, caps); } @@ -457,10 +457,10 @@ impl Threads { fn new(which: MatchKind, num_insts: uint, ncaps: uint) -> Threads { Threads { which: which, - queue: Vec::from_fn(num_insts, |_| { - Thread { pc: 0, groups: Vec::from_elem(ncaps * 2, None) } - }), - sparse: Vec::from_elem(num_insts, 0u), + queue: range(0, num_insts).map(|_| { + Thread { pc: 0, groups: repeat(None).take(ncaps * 2).collect() } + }).collect(), + sparse: repeat(0u).take(num_insts).collect(), size: 0, } } @@ -518,7 +518,7 @@ pub fn is_word(c: Option<char>) -> bool { // Try the common ASCII case before invoking binary search. match c { '_' | '0' ... '9' | 'a' ... 'z' | 'A' ... 'Z' => true, - _ => PERLW.binary_search(|&(start, end)| { + _ => PERLW.binary_search_by(|&(start, end)| { if c >= start && c <= end { Equal } else if start > c { @@ -526,7 +526,7 @@ pub fn is_word(c: Option<char>) -> bool { } else { Less } - }).found().is_some() + }).is_ok() } } |
