Skip to content
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions git-features/src/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub struct Iter<'a, I, EFN> {
pub inner: I,
make_err: Option<EFN>,
should_interrupt: &'a AtomicBool,
is_done: bool,
}

impl<'a, I, EFN, E> Iter<'a, I, EFN>
Expand All @@ -25,7 +24,6 @@ where
inner,
make_err: Some(make_err),
should_interrupt,
is_done: false,
}
}
}
Expand All @@ -38,17 +36,14 @@ where
type Item = Result<I::Item, E>;

fn next(&mut self) -> Option<Self::Item> {
if self.is_done {
return None;
}
self.make_err.as_ref()?;
if self.should_interrupt.load(Ordering::Relaxed) {
self.is_done = true;
return Some(Err(self.make_err.take().expect("no bug")()));
}
match self.inner.next() {
Some(next) => Some(Ok(next)),
None => {
self.is_done = true;
self.make_err = None;
None
}
}
Expand Down
4 changes: 2 additions & 2 deletions git-features/src/parallel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
#[cfg(feature = "parallel")]
mod in_parallel;
#[cfg(feature = "parallel")]
pub use in_parallel::*;
pub use in_parallel::{in_parallel, join};

mod serial;
#[cfg(not(feature = "parallel"))]
pub use serial::*;
pub use serial::{in_parallel, join};

mod eager_iter;
pub use eager_iter::{EagerIter, EagerIterIf};
Expand Down
2 changes: 1 addition & 1 deletion git-features/src/parallel/serial.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::parallel::Reduce;

#[cfg(not(feature = "parallel"))]
/// Runs `left` and then `right`, one after another, returning their output when both are done.
#[cfg(not(feature = "parallel"))]
pub fn join<O1: Send, O2: Send>(left: impl FnOnce() -> O1 + Send, right: impl FnOnce() -> O2 + Send) -> (O1, O2) {
(left(), right())
}
Expand Down
2 changes: 1 addition & 1 deletion git-pack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ itoa = "0.4.6"
bytesize = "1.0.1"
parking_lot = { version = "0.11.0", default-features = false }
thiserror = "1.0.26"
uluru = { version = "2.2.0", optional = true }
uluru = { version = "2.2.0", optional = true, git = "https://github.com/Byron/uluru", features = ["std"], branch = "master"}
memory-lru = { version = "0.1.0", optional = true }
dashmap = "4.0.2"

Expand Down
19 changes: 15 additions & 4 deletions git-pack/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,28 @@ pub mod lru {
/// The cache must be small as the search is 'naive' and the underlying data structure is a linked list.
/// Values of 64 seem to improve performance.
#[derive(Default)]
pub struct StaticLinkedList<const SIZE: usize>(uluru::LRUCache<Entry, SIZE>);
pub struct StaticLinkedList<const SIZE: usize>(uluru::LRUCache<Entry, SIZE>, Vec<Vec<u8>>);

impl<const SIZE: usize> DecodeEntry for StaticLinkedList<SIZE> {
fn put(&mut self, pack_id: u32, offset: u64, data: &[u8], kind: git_object::Kind, compressed_size: usize) {
self.0.insert(Entry {
if let Some(previous) = self.0.insert(Entry {
offset,
pack_id,
data: Vec::from(data),
data: self
.1
.pop()
.map(|mut v| {
v.clear();
v.resize(data.len(), 0);
v.copy_from_slice(data);
v
})
.unwrap_or_else(|| Vec::from(data)),
kind,
compressed_size,
})
}) {
self.1.push(previous.data)
}
}

fn get(&mut self, pack_id: u32, offset: u64, out: &mut Vec<u8>) -> Option<(git_object::Kind, usize)> {
Expand Down
Loading