Unified · Split
| @@ -15,22 +15,13 @@ where · 14 unmodified lines | ||
| 15 | 15 | fn contains(&self, id: impl AsRef<oid>) -> bool { |
| 16 | 16 | let id = id.as_ref(); |
| 17 | 17 | 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; | |
| 30 | 22 | } |
| 31 | 23 | } |
| 32 | 24 | |
| 33 | − let snapshot = self.snapshot.borrow(); | |
| 34 | 25 | for lodb in snapshot.loose_dbs.iter() { |
| 35 | 26 | if lodb.contains(id) { |
| 36 | 27 | return true; |
| @@ -38,9 +29,8 @@ where · 1 unmodified line | ||
| 38 | 29 | } |
| 39 | 30 | |
| 40 | 31 | 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))) => { | |
| 42 | 33 | drop(snapshot); |
| 43 | − *self.indices.borrow_mut() = std::mem::take(&mut new_snapshot.indices); | |
| 44 | 34 | *self.snapshot.borrow_mut() = new_snapshot; |
| 45 | 35 | } |
| 46 | 36 | Ok(None) => return false, // nothing more to load, or our refresh mode doesn't allow disk refreshes |
| @@ -123,14 +123,11 @@ impl super::Store { · 122 unmodified lines | ||
| 123 | 123 | refresh_mode: crate::RefreshMode, |
| 124 | 124 | ) -> super::Handle<OwnShared<super::Store>> { |
| 125 | 125 | let token = self.register_handle(); |
| 126 | − let mut snapshot = self.collect_snapshot(); | |
| 127 | − let indices = RefCell::new(std::mem::take(&mut snapshot.indices)); | |
| 128 | 126 | super::Handle { |
| 129 | 127 | store: self.clone(), |
| 130 | 128 | refresh_mode, |
| 131 | 129 | token: Some(token), |
| 132 | − snapshot: RefCell::new(snapshot), | |
| 133 | − indices, | |
| 130 | + snapshot: RefCell::new(self.collect_snapshot()), | |
| 134 | 131 | } |
| 135 | 132 | } |
| 136 | 133 | } |
| @@ -167,14 +164,11 @@ where · 30 unmodified lines | ||
| 167 | 164 | S: Deref<Target = super::Store> + Clone, |
| 168 | 165 | { |
| 169 | 166 | fn clone(&self) -> Self { |
| 170 | − let mut snapshot = self.store.collect_snapshot(); | |
| 171 | − let indices = RefCell::new(std::mem::take(&mut snapshot.indices)); | |
| 172 | 167 | super::Handle { |
| 173 | 168 | store: self.store.clone(), |
| 174 | 169 | refresh_mode: self.refresh_mode, |
| 175 | 170 | token: self.store.register_handle().into(), |
| 176 | − snapshot: RefCell::new(snapshot), | |
| 177 | − indices, | |
| 171 | + snapshot: RefCell::new(self.store.collect_snapshot()), | |
| 178 | 172 | } |
| 179 | 173 | } |
| 180 | 174 | } |
| @@ -16,7 +16,6 @@ where · 15 unmodified lines | ||
| 16 | 16 | |
| 17 | 17 | pub(crate) token: Option<handle::Mode>, |
| 18 | 18 | snapshot: RefCell<load_index::Snapshot>, |
| 19 | − indices: RefCell<Vec<handle::IndexLookup>>, | |
| 20 | 19 | } |
| 21 | 20 | |
| 22 | 21 | pub struct Store { |