diff options
Diffstat (limited to 'vendor/gix-odb/src/store_impls/dynamic/find.rs')
-rw-r--r-- | vendor/gix-odb/src/store_impls/dynamic/find.rs | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/vendor/gix-odb/src/store_impls/dynamic/find.rs b/vendor/gix-odb/src/store_impls/dynamic/find.rs index 88f95db51..b4cd25aeb 100644 --- a/vendor/gix-odb/src/store_impls/dynamic/find.rs +++ b/vendor/gix-odb/src/store_impls/dynamic/find.rs @@ -75,6 +75,7 @@ pub(crate) mod error { } } pub use error::Error; +use gix_features::zlib; use crate::{store::types::PackId, Find}; @@ -86,7 +87,8 @@ where &'b self, mut id: &'b gix_hash::oid, buffer: &'a mut Vec<u8>, - pack_cache: &mut impl DecodeEntry, + inflate: &mut zlib::Inflate, + pack_cache: &mut dyn DecodeEntry, snapshot: &mut load_index::Snapshot, recursion: Option<error::DeltaBaseRecursion<'_>>, ) -> Result<Option<(gix_object::Data<'a>, Option<gix_pack::data::entry::Location>)>, Error> { @@ -147,7 +149,8 @@ where let res = match pack.decode_entry( entry, buffer, - |id, _out| { + inflate, + &|id, _out| { index_file.pack_offset_by_id(id).map(|pack_offset| { gix_pack::data::decode::entry::ResolvedBase::InPack(pack.entry(pack_offset)) }) @@ -182,10 +185,11 @@ where .try_find_cached_inner( &base_id, &mut buf, + inflate, pack_cache, snapshot, recursion - .map(|r| r.inc_depth()) + .map(error::DeltaBaseRecursion::inc_depth) .or_else(|| error::DeltaBaseRecursion::new(id).into()), ) .map_err(|err| Error::DeltaBaseLookup { @@ -231,7 +235,8 @@ where pack.decode_entry( entry, buffer, - |id, out| { + inflate, + &|id, out| { index_file .pack_offset_by_id(id) .map(|pack_offset| { @@ -306,11 +311,8 @@ impl<S> gix_pack::Find for super::Handle<S> where S: Deref<Target = super::Store> + Clone, { - type Error = Error; - // TODO: probably make this method fallible, but that would mean its own error type. - fn contains(&self, id: impl AsRef<gix_hash::oid>) -> bool { - let id = id.as_ref(); + fn contains(&self, id: &gix_hash::oid) -> bool { let mut snapshot = self.snapshot.borrow_mut(); loop { for (idx, index) in snapshot.indices.iter().enumerate() { @@ -341,20 +343,17 @@ where fn try_find_cached<'a>( &self, - id: impl AsRef<gix_hash::oid>, + id: &gix_hash::oid, buffer: &'a mut Vec<u8>, - pack_cache: &mut impl DecodeEntry, - ) -> Result<Option<(gix_object::Data<'a>, Option<gix_pack::data::entry::Location>)>, Self::Error> { - let id = id.as_ref(); + pack_cache: &mut dyn DecodeEntry, + ) -> Result<Option<(gix_object::Data<'a>, Option<gix_pack::data::entry::Location>)>, gix_pack::find::Error> { let mut snapshot = self.snapshot.borrow_mut(); - self.try_find_cached_inner(id, buffer, pack_cache, &mut snapshot, None) + let mut inflate = self.inflate.borrow_mut(); + self.try_find_cached_inner(id, buffer, &mut inflate, pack_cache, &mut snapshot, None) + .map_err(|err| Box::new(err) as _) } - fn location_by_oid( - &self, - id: impl AsRef<gix_hash::oid>, - buf: &mut Vec<u8>, - ) -> Option<gix_pack::data::entry::Location> { + fn location_by_oid(&self, id: &gix_hash::oid, buf: &mut Vec<u8>) -> Option<gix_pack::data::entry::Location> { assert!( matches!(self.token.as_ref(), Some(handle::Mode::KeepDeletedPacksAvailable)), "BUG: handle must be configured to `prevent_pack_unload()` before using this method" @@ -362,8 +361,8 @@ where assert!(self.store_ref().replacements.is_empty() || self.ignore_replacements, "Everything related to packing must not use replacements. These are not used here, but it should be turned off for good measure."); - let id = id.as_ref(); let mut snapshot = self.snapshot.borrow_mut(); + let mut inflate = self.inflate.borrow_mut(); 'outer: loop { { let marker = snapshot.marker; @@ -404,13 +403,14 @@ where buf.resize(entry.decompressed_size.try_into().expect("representable size"), 0); assert_eq!(pack.id, pack_id.to_intrinsic_pack_id(), "both ids must always match"); - let res = pack.decompress_entry(&entry, buf).ok().map(|entry_size_past_header| { - gix_pack::data::entry::Location { + let res = pack + .decompress_entry(&entry, &mut inflate, buf) + .ok() + .map(|entry_size_past_header| gix_pack::data::entry::Location { pack_id: pack.id, pack_offset, entry_size: entry.header_size() + entry_size_past_header, - } - }); + }); if idx != 0 { snapshot.indices.swap(0, idx); @@ -503,17 +503,15 @@ where S: Deref<Target = super::Store> + Clone, Self: gix_pack::Find, { - type Error = <Self as gix_pack::Find>::Error; - - fn contains(&self, id: impl AsRef<gix_hash::oid>) -> bool { + fn contains(&self, id: &gix_hash::oid) -> bool { gix_pack::Find::contains(self, id) } fn try_find<'a>( &self, - id: impl AsRef<gix_hash::oid>, + id: &gix_hash::oid, buffer: &'a mut Vec<u8>, - ) -> Result<Option<gix_object::Data<'a>>, Self::Error> { + ) -> Result<Option<gix_object::Data<'a>>, crate::find::Error> { gix_pack::Find::try_find(self, id, buffer).map(|t| t.map(|t| t.0)) } } |