Skip to content

Commit f0b92ca

Browse files
committed
bench: update to memmap 0.6
1 parent 9ee9943 commit f0b92ca

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

bench/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ lazy_static = "1"
1717
libc = "0.2"
1818
onig = { version = "3", optional = true }
1919
libpcre-sys = { version = "0.2", optional = true }
20-
memmap = "0.2"
20+
memmap = "0.6"
2121
regex = { version = "0.2.0", path = "..", features = ["simd-accel"] }
2222
regex-syntax = { version = "0.4.0", path = "../regex-syntax" }
2323
serde = "1"

bench/src/main.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ extern crate serde;
2626
#[macro_use]
2727
extern crate serde_derive;
2828

29+
use std::fs::File;
2930
use std::str;
3031

3132
use docopt::Docopt;
32-
use memmap::{Mmap, Protection};
33+
use memmap::Mmap;
3334

3435
mod ffi;
3536

@@ -69,8 +70,10 @@ fn main() {
6970
.and_then(|d| d.deserialize())
7071
.unwrap_or_else(|e| e.exit());
7172

72-
let mmap = Mmap::open_path(&args.arg_file, Protection::Read).unwrap();
73-
let haystack = unsafe { str::from_utf8_unchecked(mmap.as_slice()) };
73+
let mmap = unsafe {
74+
Mmap::map(&File::open(&args.arg_file).unwrap()).unwrap()
75+
};
76+
let haystack = unsafe { str::from_utf8_unchecked(&mmap) };
7477

7578
println!("{}", args.count(&haystack));
7679
}

0 commit comments

Comments
 (0)