Skip to content

Commit 9e9b9fe

Browse files
committed
Merge branch 'mmap-mode'
2 parents 35592c9 + 88061a1 commit 9e9b9fe

File tree

6 files changed

+8
-13
lines changed

6 files changed

+8
-13
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix-commitgraph/src/file/init.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ use std::{
44
path::Path,
55
};
66

7-
use bstr::ByteSlice;
8-
use memmap2::Mmap;
9-
107
use crate::{
118
file::{
129
ChunkId, BASE_GRAPHS_LIST_CHUNK_ID, COMMIT_DATA_CHUNK_ID, COMMIT_DATA_ENTRY_SIZE_SANS_HASH,
1310
EXTENDED_EDGES_LIST_CHUNK_ID, FAN_LEN, HEADER_LEN, OID_FAN_CHUNK_ID, OID_LOOKUP_CHUNK_ID, SIGNATURE,
1411
},
1512
File,
1613
};
14+
use bstr::ByteSlice;
1715

1816
/// The error used in [`File::at()`].
1917
#[derive(thiserror::Error, Debug)]
@@ -246,7 +244,7 @@ impl TryFrom<&Path> for File {
246244
// SAFETY: we have to take the risk of somebody changing the file underneath. Git never writes into the same file.
247245
#[allow(unsafe_code)]
248246
unsafe {
249-
Mmap::map(&file)
247+
memmap2::MmapOptions::new().map_copy_read_only(&file)
250248
}
251249
})
252250
.map_err(|e| Error::Io {

gix-index/src/file/init.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
use std::path::{Path, PathBuf};
44

5-
use memmap2::Mmap;
6-
75
use crate::{decode, extension, File, State};
86

97
mod error {
@@ -64,7 +62,7 @@ impl File {
6462
let mut file = std::fs::File::open(&path)?;
6563
// SAFETY: we have to take the risk of somebody changing the file underneath. Git never writes into the same file.
6664
#[allow(unsafe_code)]
67-
let data = unsafe { Mmap::map(&file)? };
65+
let data = unsafe { memmap2::MmapOptions::new().map_copy_read_only(&file)? };
6866

6967
if !skip_hash {
7068
// Note that even though it's trivial to offload this into a thread, which is worth it for all but the smallest

gix-pack/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ mod mmap {
5555
// SAFETY: we have to take the risk of somebody changing the file underneath. Git never writes into the same file.
5656
#[allow(unsafe_code)]
5757
unsafe {
58-
memmap2::Mmap::map(&file)
58+
memmap2::MmapOptions::new().map_copy_read_only(&file)
5959
}
6060
}
6161
}

gix-pack/tests/pack/index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ mod version {
148148
desired_kind,
149149
|| {
150150
let file = std::fs::File::open(fixture_path(data_path))?;
151-
let map = unsafe { memmap2::Mmap::map(&file)? };
151+
let map = unsafe { memmap2::MmapOptions::map_copy_read_only(&file)? };
152152
Ok((slice_map, map))
153153
},
154154
pack_iter,

gix-ref/src/store/packed/buffer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ impl AsRef<[u8]> for packed::Backing {
1919
pub mod open {
2020
use std::path::PathBuf;
2121

22-
use memmap2::Mmap;
2322
use winnow::{prelude::*, stream::Offset};
2423

2524
use crate::store_impl::packed;
@@ -81,7 +80,7 @@ pub mod open {
8180
// SAFETY: we have to take the risk of somebody changing the file underneath. Git never writes into the same file.
8281
#[allow(unsafe_code)]
8382
unsafe {
84-
Mmap::map(&std::fs::File::open(&path)?)?
83+
memmap2::MmapOptions::new().map_copy_read_only(&std::fs::File::open(&path)?)?
8584
},
8685
)
8786
};

0 commit comments

Comments
 (0)