move interactive function init out of main loop
authorMike Frysinger <vapier@gentoo.org>
Wed, 3 Jun 2015 13:24:48 +0000 (21:24 +0800)
committerMike Frysinger <vapier@gentoo.org>
Wed, 3 Jun 2015 13:24:48 +0000 (21:24 +0800)
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

index 2dd1cada56578705b706a36424c527f83468efd0..abdcc3991b985838bcd29499324a1c34ced11485 100644 (file)
@@ -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::string>&);
+  std::map<std::string,interactive_func> 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::string>&);
-    std::map<std::string,interactive_func> 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))