Skip to content

Commit a346bcc

Browse files
committed
feat: add Index::entries_mut_and_pathbacking().
With it one can read entries and read paths at the same time.
1 parent 4961b33 commit a346bcc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

gix-index/src/access/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ impl State {
132132
pub fn entries_mut(&mut self) -> &mut [Entry] {
133133
&mut self.entries
134134
}
135+
136+
/// Return a writable slice to entries and read-access to their path storage at the same time.
137+
pub fn entries_mut_and_pathbacking(&mut self) -> (&mut [Entry], &PathStorage) {
138+
(&mut self.entries, &self.path_backing)
139+
}
140+
135141
/// Return mutable entries along with their paths in an iterator.
136142
pub fn entries_mut_with_paths(&mut self) -> impl Iterator<Item = (&mut Entry, &BStr)> {
137143
let paths = &self.path_backing;

gix-index/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ pub struct State {
9393
/// same timestamp as this as potentially changed, checking more thoroughly if a change actually happened.
9494
timestamp: FileTime,
9595
version: Version,
96-
///
97-
pub entries: Vec<Entry>,
96+
entries: Vec<Entry>,
9897
/// A memory area keeping all index paths, in full length, independently of the index version.
9998
///
10099
/// Ranges into this storage are referred to by parts of `entries`.
101-
pub path_backing: PathStorage,
100+
path_backing: PathStorage,
102101
/// True if one entry in the index has a special marker mode
103102
is_sparse: bool,
104103

0 commit comments

Comments
 (0)