History

Add odb handle to state (#266)

Sebastian Thiel committed 4 years ago

Commit 4e38da31 parent 93db4a52 files · +10 −9Browse files

Unified · Split

2 files
  1. git-repository/src/easy/mod.rs +2 −1
  2. git-repository/src/easy/state.rs +8 −8
git-repository/src/easy/mod.rs+2−1
@@ -112,8 +112,9 @@ type PackCache = Box<dyn git_pack::cache::DecodeEntry + Send + 'static>; · 111 unmodified lines
112112 /// those who experiment with workloads to get speed boosts of 2x or more.
113113 pub struct State {
114114 /// As the packed-buffer may hold onto a memory map, so ideally this State is freed after use instead of keeping it around
115− /// for too long. At least `packed_refs` is lazily initialized.
115+ /// for too long. At least `packed_refs` is lazily initialized though.
116116 refs: crate::RefStore,
117+ objects: crate::OdbHandle,
117118 pack_cache: RefCell<PackCache>,
118119 object_cache: RefCell<Option<object::cache::MemoryCappedHashmap>>,
119120 buf: RefCell<Vec<u8>>,
git-repository/src/easy/state.rs+8−8
@@ -1,17 +1,16 @@
11 //!
22 use std::cell::{Ref, RefCell, RefMut};
33
4−use crate::{easy, easy::borrow, Repository};
4+use crate::{easy, easy::borrow};
55
66 impl Clone for easy::State {
77 fn clone(&self) -> Self {
8− self.refs.clone().into()
8+ easy::State::from_refs_and_objects(self.refs.clone(), self.objects.clone())
99 }
1010 }
1111
12−// TODO: Expand this as needed as more higher-level stores exist (i.e. odb)
13−impl From<crate::RefStore> for easy::State {
14− fn from(refs: crate::RefStore) -> Self {
12+impl easy::State {
13+ pub(crate) fn from_refs_and_objects(refs: crate::RefStore, objects: crate::OdbHandle) -> Self {
1514 easy::State {
1615 #[cfg(not(feature = "max-performance"))]
1716 pack_cache: RefCell::new(git_pack::cache::Never),
@@ -19,14 +18,15 @@ impl From<crate::RefStore> for easy::State { · 1 unmodified line
1918 pack_cache: RefCell::new(Box::new(git_pack::cache::lru::StaticLinkedList::<64>::default())),
2019 object_cache: RefCell::new(None),
2120 buf: RefCell::new(vec![]),
21+ objects,
2222 refs,
2323 }
2424 }
2525 }
2626
27−impl From<&Repository> for easy::State {
28− fn from(repo: &Repository) -> Self {
29− repo.refs.clone().into()
27+impl From<&crate::Repository> for easy::State {
28+ fn from(repo: &crate::Repository) -> Self {
29+ easy::State::from_refs_and_objects(repo.refs.clone(), repo.odb.to_handle_shared())
3030 }
3131 }
3232