diff --git a/crates/interpreter/src/interpreter.rs b/crates/interpreter/src/interpreter.rs index 1d415772288..15f4f18594f 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.bytes().clone(); Self { instruction_pointer: bytecode.as_ptr(), bytecode, diff --git a/crates/primitives/src/bytecode.rs b/crates/primitives/src/bytecode.rs index 6236c3ea847..a26b0fdb99b 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 bytes(&self) -> &Bytes { match self { - Self::LegacyRaw(bytes) => bytes.clone(), + Self::LegacyRaw(bytes) => bytes, Self::LegacyAnalyzed(analyzed) => analyzed.bytes(), 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 3e6f2d2b907..75b1aae8c3f 100644 --- a/crates/primitives/src/bytecode/legacy.rs +++ b/crates/primitives/src/bytecode/legacy.rs @@ -42,8 +42,8 @@ impl LegacyAnalyzedBytecode { /// Returns bytes of bytecode. /// /// Bytes are padded with 32 zero bytes. - pub fn bytes(&self) -> Bytes { - self.bytecode.clone() + pub fn bytes(&self) -> &Bytes { + &self.bytecode } /// Original bytes length.