From d9b0317b920fb10a74241d9d1bc1e626bb8cc8ac Mon Sep 17 00:00:00 2001 From: Evan Mesterhazy Date: Sat, 2 Mar 2024 14:36:57 -0500 Subject: [PATCH] Store OpHeadsStore in UnpublishedOperation instead of RepoLoader The only thing we need from the `RepoLoader` is the `OpHeadsStore`, so we can extract it in UnpublishedOperation::new instead of keeping the entire `RepoLoader` around. --- lib/src/transaction.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index cceb2c36dd..7caa046dfc 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -20,6 +20,7 @@ use itertools::Itertools as _; use crate::backend::Timestamp; use crate::index::ReadonlyIndex; +use crate::op_heads_store::OpHeadsStore; use crate::op_store::OperationMetadata; use crate::operation::Operation; use crate::repo::{MutableRepo, ReadonlyRepo, Repo, RepoLoader, RepoLoaderError}; @@ -149,7 +150,7 @@ pub fn create_op_metadata( #[must_use = "Either publish() or leave_unpublished() must be called on UnpublishedOperation."] pub struct UnpublishedOperation { - repo_loader: RepoLoader, + op_heads_store: Arc, repo: Arc, } @@ -161,7 +162,7 @@ impl UnpublishedOperation { index: Box, ) -> Self { UnpublishedOperation { - repo_loader, + op_heads_store: repo_loader.op_heads_store().clone(), repo: repo_loader.create_from(operation, view, index), } } @@ -171,9 +172,8 @@ impl UnpublishedOperation { } pub fn publish(self) -> Arc { - let _lock = self.repo_loader.op_heads_store().lock(); - self.repo_loader - .op_heads_store() + let _lock = self.op_heads_store.lock(); + self.op_heads_store .update_op_heads(self.operation().parent_ids(), self.operation().id()); self.repo }