From c7a11418bbb55e217f416cd35e9e4de7c3777781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 12 Jul 2016 10:28:42 +0200 Subject: [PATCH] Getting rid of get_info --- ethcore/src/evm/instructions.rs | 7 +------ ethcore/src/evm/interpreter/mod.rs | 3 ++- ethcore/src/evm/mod.rs | 1 - ethcore/src/lib.rs | 1 - 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/ethcore/src/evm/instructions.rs b/ethcore/src/evm/instructions.rs index 9e7527fa3..62cfe77d6 100644 --- a/ethcore/src/evm/instructions.rs +++ b/ethcore/src/evm/instructions.rs @@ -146,7 +146,7 @@ impl InstructionInfo { } lazy_static! { - static ref INSTRUCTIONS: [InstructionInfo; 0x100] = { + pub static ref INSTRUCTIONS: [InstructionInfo; 0x100] = { let mut arr = [InstructionInfo::default(); 0x100]; arr[STOP as usize] = InstructionInfo::new("STOP", 0, 0, 0, true, GasPriceTier::Zero); arr[ADD as usize] = InstructionInfo::new("ADD", 0, 2, 1, false, GasPriceTier::VeryLow); @@ -282,11 +282,6 @@ lazy_static! { }; } -/// Return details about specific instruction -pub fn get_info(instruction: Instruction) -> &'static InstructionInfo { - &INSTRUCTIONS[instruction as usize] -} - /// Virtual machine bytecode instruction. /// halts execution pub const STOP: Instruction = 0x00; diff --git a/ethcore/src/evm/interpreter/mod.rs b/ethcore/src/evm/interpreter/mod.rs index f79d18b36..a43592c6d 100644 --- a/ethcore/src/evm/interpreter/mod.rs +++ b/ethcore/src/evm/interpreter/mod.rs @@ -104,12 +104,13 @@ impl evm::Evm for Interpreter { position: 0, code: &code }; + let infos = &*instructions::INSTRUCTIONS; while reader.position < code.len() { let instruction = code[reader.position]; reader.position += 1; - let info = instructions::get_info(instruction); + let info = infos[instruction as usize]; try!(self.verify_instruction(ext, instruction, &info, &stack)); // Calculate gas cost diff --git a/ethcore/src/evm/mod.rs b/ethcore/src/evm/mod.rs index de208c6a4..d0f379f24 100644 --- a/ethcore/src/evm/mod.rs +++ b/ethcore/src/evm/mod.rs @@ -35,4 +35,3 @@ pub use self::evm::{Evm, Error, Finalize, GasLeft, Result, CostType}; pub use self::ext::{Ext, ContractCreateResult, MessageCallResult}; pub use self::factory::{Factory, VMType}; pub use self::schedule::Schedule; -pub use self::instructions::get_info; diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 4f644db03..9f4f02491 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -146,5 +146,4 @@ mod tests; mod json_tests; pub use types::*; -pub use evm::get_info; pub use executive::contract_address;