Skip to content

Commit b5ef498

Browse files
committed
Use reference to ContractsDataStore instead clone
1 parent b2dbbce commit b5ef498

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

crates/debugging/src/trace/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use starknet_api::execution_utils::format_panic_data;
1515

1616
pub struct Collector<'a> {
1717
call_trace: &'a CallTrace,
18-
context: &'a Context,
18+
context: &'a Context<'a>,
1919
}
2020

2121
impl<'a> Collector<'a> {

crates/debugging/src/trace/context.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ use crate::Components;
22
use crate::contracts_data_store::ContractsDataStore;
33

44
/// Context is a structure that holds the necessary data for creating a [`Trace`](crate::Trace).
5-
pub struct Context {
6-
contracts_data_store: ContractsDataStore,
5+
pub struct Context<'a> {
6+
contracts_data_store: &'a ContractsDataStore,
77
components: Components,
88
}
99

10-
impl Context {
11-
/// Creates a new instance of [`Context`] from a given `cheatnet` [`ContractsData`], [`ForkData`] and [`Components`].
10+
impl<'a> Context<'a> {
11+
/// Creates a new instance of [`Context`] from a given [`ContractsDataStore`] and [`Components`].
1212
#[must_use]
13-
pub fn new(contracts_data_store: ContractsDataStore, components: Components) -> Self {
13+
pub fn new(
14+
contracts_data_store: &'a ContractsDataStore,
15+
components: Components,
16+
) -> Context<'a> {
1417
Self {
1518
contracts_data_store,
1619
components,
@@ -20,7 +23,7 @@ impl Context {
2023
/// Returns a reference to the [`ContractsDataStore`].
2124
#[must_use]
2225
pub fn contracts_data_store(&self) -> &ContractsDataStore {
23-
&self.contracts_data_store
26+
self.contracts_data_store
2427
}
2528

2629
/// Returns a reference to the [`Components`].

crates/forge-runner/src/debugging/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ pub fn build_debugging_trace(
1616
test_name: String,
1717
) -> Option<debugging::Trace> {
1818
let components = trace_args.to_components()?;
19-
let context = debugging::Context::new(contracts_data_store.clone(), components);
19+
let context = debugging::Context::new(contracts_data_store, components);
2020
Some(debugging::Trace::new(call_trace, &context, test_name))
2121
}

0 commit comments

Comments
 (0)