History

Try reusing mappings, but no LRU(#266)

Sebastian Thiel committed 4 years ago

Commit bb602e81 parent 2d6960f3 files · +7 −24Browse files

Unified · Split

3 files
  1. git-odb/src/store/general/find.rs +5 −15
  2. git-odb/src/store/general/handle.rs +2 −8
  3. git-odb/src/store/general/mod.rs +0 −1
git-odb/src/store/general/find.rs+5−15
@@ -15,22 +15,13 @@ where · 14 unmodified lines
1515 fn contains(&self, id: impl AsRef<oid>) -> bool {
1616 let id = id.as_ref();
1717 loop {
18− {
19− let mut indices = self.indices.borrow_mut();
20− let mut iter = indices.iter();
21− let mut idx = 0;
22− while let Some(index) = iter.next() {
23− if index.contains(id) {
24− if idx != 0 {
25− indices.swap(0, idx);
26− }
27− return true;
28− }
29− idx += 1;
18+ let snapshot = self.snapshot.borrow();
19+ for index in &snapshot.indices {
20+ if index.contains(id) {
21+ return true;
3022 }
3123 }
3224
33− let snapshot = self.snapshot.borrow();
3425 for lodb in snapshot.loose_dbs.iter() {
3526 if lodb.contains(id) {
3627 return true;
@@ -38,9 +29,8 @@ where · 1 unmodified line
3829 }
3930
4031 match self.store.load_one_index(self.refresh_mode, &snapshot.marker) {
41− Ok(Some(load_index::Outcome::Replace(mut new_snapshot))) => {
32+ Ok(Some(load_index::Outcome::Replace(new_snapshot))) => {
4233 drop(snapshot);
43− *self.indices.borrow_mut() = std::mem::take(&mut new_snapshot.indices);
4434 *self.snapshot.borrow_mut() = new_snapshot;
4535 }
4636 Ok(None) => return false, // nothing more to load, or our refresh mode doesn't allow disk refreshes
git-odb/src/store/general/handle.rs+2−8
@@ -123,14 +123,11 @@ impl super::Store { · 122 unmodified lines
123123 refresh_mode: crate::RefreshMode,
124124 ) -> super::Handle<OwnShared<super::Store>> {
125125 let token = self.register_handle();
126− let mut snapshot = self.collect_snapshot();
127− let indices = RefCell::new(std::mem::take(&mut snapshot.indices));
128126 super::Handle {
129127 store: self.clone(),
130128 refresh_mode,
131129 token: Some(token),
132− snapshot: RefCell::new(snapshot),
133− indices,
130+ snapshot: RefCell::new(self.collect_snapshot()),
134131 }
135132 }
136133 }
@@ -167,14 +164,11 @@ where · 30 unmodified lines
167164 S: Deref<Target = super::Store> + Clone,
168165 {
169166 fn clone(&self) -> Self {
170− let mut snapshot = self.store.collect_snapshot();
171− let indices = RefCell::new(std::mem::take(&mut snapshot.indices));
172167 super::Handle {
173168 store: self.store.clone(),
174169 refresh_mode: self.refresh_mode,
175170 token: self.store.register_handle().into(),
176− snapshot: RefCell::new(snapshot),
177− indices,
171+ snapshot: RefCell::new(self.store.collect_snapshot()),
178172 }
179173 }
180174 }
git-odb/src/store/general/mod.rs+0−1
@@ -16,7 +16,6 @@ where · 15 unmodified lines
1616
1717 pub(crate) token: Option<handle::Mode>,
1818 snapshot: RefCell<load_index::Snapshot>,
19− indices: RefCell<Vec<handle::IndexLookup>>,
2019 }
2120
2221 pub struct Store {