1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-06-25 14:22:54 +02:00

Update to memmap 0.6

`memmap` 0.6.0 introduces major API changes in anticipation of a 1.0
release. See https://github.com/danburkert/memmap-rs/releases/tag/0.6.0
for more information. CC danburkert/memmap-rs#33.
This commit is contained in:
Dan Burkert
2017-10-28 15:32:43 -07:00
committed by Andrew Gallant
parent 231698f802
commit 263e8f92b9
3 changed files with 28 additions and 40 deletions

View File

@ -5,7 +5,7 @@ use std::path::Path;
use encoding_rs::Encoding;
use grep::Grep;
use ignore::DirEntry;
use memmap::{Mmap, Protection};
use memmap::Mmap;
use termcolor::WriteColor;
use decoder::DecodeReader;
@ -290,8 +290,8 @@ impl Worker {
// regular read calls.
return self.search(printer, path, file);
}
let mmap = try!(Mmap::open(file, Protection::Read));
let buf = unsafe { mmap.as_slice() };
let mmap = unsafe { try!(Mmap::map(file)) };
let buf = &*mmap;
if buf.len() >= 3 && Encoding::for_bom(buf).is_some() {
// If we have a UTF-16 bom in our memory map, then we need to fall
// back to the stream reader, which will do transcoding.