From eaa203c4ed1629fc826e66050bae177373789fcb Mon Sep 17 00:00:00 2001 From: Michal Strug Date: Mon, 9 Dec 2024 23:06:45 +0100 Subject: [PATCH] Small optimization --- crates/orderbook/src/orderbook.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/orderbook/src/orderbook.rs b/crates/orderbook/src/orderbook.rs index 063fa0aff5..3a55d2c423 100644 --- a/crates/orderbook/src/orderbook.rs +++ b/crates/orderbook/src/orderbook.rs @@ -254,17 +254,18 @@ impl Orderbook { self.replace_order(order, old_order, quote).await } else { let quote_id = quote.as_ref().and_then(|quote| quote.id); + let order_uid = order.metadata.uid; self.database .insert_order(&order, quote.clone()) .await .map_err(|err| AddOrderError::from_insertion(err, &order))?; Metrics::on_order_operation( - &OrderWithQuote::try_new(order.clone(), quote)?, + &OrderWithQuote::try_new(order, quote)?, OrderOperation::Created, ); - Ok((order.metadata.uid, quote_id)) + Ok((order_uid, quote_id)) } } @@ -407,6 +408,7 @@ impl Orderbook { } let quote_id = quote.as_ref().and_then(|quote| quote.id); + let order_uid = validated_new_order.metadata.uid; self.database .replace_order( @@ -418,11 +420,11 @@ impl Orderbook { .map_err(|err| AddOrderError::from_insertion(err, &validated_new_order))?; Metrics::on_order_operation(&old_order, OrderOperation::Cancelled); Metrics::on_order_operation( - &OrderWithQuote::try_new(validated_new_order.clone(), quote)?, + &OrderWithQuote::try_new(validated_new_order, quote)?, OrderOperation::Created, ); - Ok((validated_new_order.metadata.uid, quote_id)) + Ok((order_uid, quote_id)) } pub async fn get_order(&self, uid: &OrderUid) -> Result> {