From 080e64a6a23b1ca2be9d603bc642c128d413dd7d Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 3 Jun 2015 21:24:48 +0800 Subject: [PATCH] move interactive function init out of main loop These values don't change between runs, so there's no point in recreating them on every instruction step. Pull it out to the top to simplify. --- riscv/interactive.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/riscv/interactive.cc b/riscv/interactive.cc index 2dd1cad..abdcc39 100644 --- a/riscv/interactive.cc +++ b/riscv/interactive.cc @@ -48,6 +48,20 @@ static std::string readline(int fd) void sim_t::interactive() { + typedef void (sim_t::*interactive_func)(const std::string&, const std::vector&); + std::map funcs; + + funcs["r"] = &sim_t::interactive_run_noisy; + funcs["rs"] = &sim_t::interactive_run_silent; + funcs["reg"] = &sim_t::interactive_reg; + funcs["fregs"] = &sim_t::interactive_fregs; + funcs["fregd"] = &sim_t::interactive_fregd; + funcs["mem"] = &sim_t::interactive_mem; + funcs["str"] = &sim_t::interactive_str; + funcs["until"] = &sim_t::interactive_until; + funcs["while"] = &sim_t::interactive_until; + funcs["q"] = &sim_t::interactive_quit; + while (!htif->done()) { std::cerr << ": " << std::flush; @@ -67,20 +81,6 @@ void sim_t::interactive() while (ss >> tmp) args.push_back(tmp); - typedef void (sim_t::*interactive_func)(const std::string&, const std::vector&); - std::map funcs; - - funcs["r"] = &sim_t::interactive_run_noisy; - funcs["rs"] = &sim_t::interactive_run_silent; - funcs["reg"] = &sim_t::interactive_reg; - funcs["fregs"] = &sim_t::interactive_fregs; - funcs["fregd"] = &sim_t::interactive_fregd; - funcs["mem"] = &sim_t::interactive_mem; - funcs["str"] = &sim_t::interactive_str; - funcs["until"] = &sim_t::interactive_until; - funcs["while"] = &sim_t::interactive_until; - funcs["q"] = &sim_t::interactive_quit; - try { if(funcs.count(cmd)) -- 2.30.2