From 073310547caca187a080c5af3c2baf759a93e623 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 22 Feb 2024 17:04:07 +0900 Subject: [PATCH] operation: make Operation object cheaply clonable We do clone Operation object in several places, and I'm going to add one more .clone() in the templater. Since the underlying metadata has many fields, I think it's better to wrap it with Arc just like a Commit object. --- lib/src/operation.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/src/operation.rs b/lib/src/operation.rs index 896ab8ce2..8f09e8142 100644 --- a/lib/src/operation.rs +++ b/lib/src/operation.rs @@ -27,7 +27,7 @@ use crate::view::View; pub struct Operation { op_store: Arc, id: OperationId, - data: op_store::Operation, + data: Arc, // allow cheap clone } impl Debug for Operation { @@ -63,8 +63,16 @@ impl Hash for Operation { } impl Operation { - pub fn new(op_store: Arc, id: OperationId, data: op_store::Operation) -> Self { - Operation { op_store, id, data } + pub fn new( + op_store: Arc, + id: OperationId, + data: impl Into>, + ) -> Self { + Operation { + op_store, + id, + data: data.into(), + } } pub fn op_store(&self) -> Arc {