Skip to content

Commit

Permalink
chore: reduce size of DynCheatcode vtable (#9023)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Oct 3, 2024
1 parent 67018dc commit e10ab3d
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions crates/cheatcodes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,9 @@ pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode {
}
}

pub(crate) trait DynCheatcode {
pub(crate) trait DynCheatcode: 'static {
fn cheatcode(&self) -> &'static spec::Cheatcode<'static>;

fn name(&self) -> &'static str {
self.cheatcode().func.signature.split('(').next().unwrap()
}

fn id(&self) -> &'static str {
self.cheatcode().func.id
}

fn signature(&self) -> &'static str {
self.cheatcode().func.signature
}

fn status(&self) -> &Status<'static> {
&self.cheatcode().status
}

fn as_debug(&self) -> &dyn std::fmt::Debug;

fn dyn_apply(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result;
Expand All @@ -125,6 +109,24 @@ impl<T: Cheatcode> DynCheatcode for T {
}
}

impl dyn DynCheatcode {
pub(crate) fn name(&self) -> &'static str {
self.cheatcode().func.signature.split('(').next().unwrap()
}

pub(crate) fn id(&self) -> &'static str {
self.cheatcode().func.id
}

pub(crate) fn signature(&self) -> &'static str {
self.cheatcode().func.signature
}

pub(crate) fn status(&self) -> &Status<'static> {
&self.cheatcode().status
}
}

/// The cheatcode context, used in `Cheatcode`.
pub struct CheatsCtxt<'cheats, 'evm, 'db, 'db2> {
/// The cheatcodes inspector state.
Expand Down

0 comments on commit e10ab3d

Please sign in to comment.