Minor re-arrangement for compatibiility.
This commit is contained in:
parent
40811151ab
commit
a6d4fda582
|
@ -1,11 +1,13 @@
|
||||||
use squozen::prepare_pattern::prepare_pattern;
|
use squozen::prepare_pattern::prepare_pattern_raw;
|
||||||
|
|
||||||
const COUNT: usize = 5 * 1000 * 1000 * 100;
|
const COUNT: usize = 5 * 1000 * 1000 * 100;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut end = COUNT;
|
let mut end = COUNT;
|
||||||
|
let mut dest = Vec::<u8>::with_capacity(100);
|
||||||
while end > 0 {
|
while end > 0 {
|
||||||
let _g = prepare_pattern(b"/foo/bar/whatever[0-9]*");
|
dest.clear();
|
||||||
|
prepare_pattern_raw(b"/foo/bar/whatever[0-9]*", &mut dest);
|
||||||
end = end - 1;
|
end = end - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub fn prepare_pattern(name: &[u8]) -> Vec<u8> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn prepare_pattern_raw(name: &[u8], dest: &mut Vec<u8>) {
|
pub fn prepare_pattern_raw(name: &[u8], dest: &mut Vec<u8>) {
|
||||||
let mut eol = name.len();
|
let eol = name.len();
|
||||||
if eol == 0 {
|
if eol == 0 {
|
||||||
panic!("Library error - This function should never be called with an empty string.")
|
panic!("Library error - This function should never be called with an empty string.")
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ pub fn prepare_pattern_raw(name: &[u8], dest: &mut Vec<u8>) {
|
||||||
// After this point, eol always points to the index from where we want to
|
// After this point, eol always points to the index from where we want to
|
||||||
// stop, not to the character beyond that.
|
// stop, not to the character beyond that.
|
||||||
|
|
||||||
eol = hunt(name, eol - 1, 0, |&c| c != b'*' && c != b'?');
|
let mut eol = hunt(name, eol - 1, 0, |&c| c != b'*' && c != b'?');
|
||||||
if name[eol] == b']' {
|
if name[eol] == b']' {
|
||||||
eol = hunt(&name, eol - 1, 0, |&c| c == b'[');
|
eol = hunt(&name, eol - 1, 0, |&c| c == b'[');
|
||||||
eol = if eol > 0 { eol - 1 } else { 0 }
|
eol = if eol > 0 { eol - 1 } else { 0 }
|
||||||
|
|
Loading…
Reference in New Issue