From: Mike Frysinger Date: Wed, 3 Jun 2015 13:24:48 +0000 (+0800) Subject: move interactive function init out of main loop X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=080e64a6a23b1ca2be9d603bc642c128d413dd7d;p=riscv-isa-sim.git 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. --- 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))