diff --git a/crates/interpreter/src/interpreter.rs b/crates/interpreter/src/interpreter.rs index 1d41577228..18921a6877 100644 --- a/crates/interpreter/src/interpreter.rs +++ b/crates/interpreter/src/interpreter.rs @@ -87,7 +87,7 @@ impl Interpreter { panic!("Contract is not execution ready {:?}", contract.bytecode); } let is_eof = contract.bytecode.is_eof(); - let bytecode = contract.bytecode.bytecode_bytes(); + let bytecode = contract.bytecode.bytecode().clone(); Self { instruction_pointer: bytecode.as_ptr(), bytecode, diff --git a/crates/primitives/src/bytecode.rs b/crates/primitives/src/bytecode.rs index 6236c3ea84..2e44672659 100644 --- a/crates/primitives/src/bytecode.rs +++ b/crates/primitives/src/bytecode.rs @@ -91,17 +91,17 @@ impl Bytecode { } /// Returns a reference to the bytecode. + /// /// In case of EOF this will be the first code section. #[inline] - pub fn bytecode_bytes(&self) -> Bytes { + pub fn bytecode(&self) -> &Bytes { match self { - Self::LegacyRaw(bytes) => bytes.clone(), - Self::LegacyAnalyzed(analyzed) => analyzed.bytes(), + Self::LegacyRaw(bytes) => bytes, + Self::LegacyAnalyzed(analyzed) => analyzed.bytecode(), Self::Eof(eof) => eof .body .code(0) - .expect("Valid EOF has at least one code section") - .clone(), + .expect("Valid EOF has at least one code section"), } } diff --git a/crates/primitives/src/bytecode/legacy.rs b/crates/primitives/src/bytecode/legacy.rs index 3e6f2d2b90..2a44fefd43 100644 --- a/crates/primitives/src/bytecode/legacy.rs +++ b/crates/primitives/src/bytecode/legacy.rs @@ -39,11 +39,11 @@ impl LegacyAnalyzedBytecode { } } - /// Returns bytes of bytecode. + /// Returns a reference to the bytecode. /// - /// Bytes are padded with 32 zero bytes. - pub fn bytes(&self) -> Bytes { - self.bytecode.clone() + /// The bytecode is padded with 32 zero bytes. + pub fn bytecode(&self) -> &Bytes { + &self.bytecode } /// Original bytes length.