diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-19 14:15:18 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-19 14:15:18 +0800 |
commit | 7b4f5efee4484b856652ac9c86409cb6dee1941b (patch) | |
tree | be9a1beb7e7c334bd28f2c53aec0e527fbdfd8d2 /src/main.cpp | |
parent | e81715bc5339ae372a4b7df561cf9a116444c9da (diff) | |
download | mrust-7b4f5efee4484b856652ac9c86409cb6dee1941b.tar.gz |
main - Cache debug enabled result
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index 7e0d1188..2ad64c4c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,6 +26,7 @@ #include "expand/cfg.hpp"
int g_debug_indent_level = 0;
+bool g_debug_enabled = true;
::std::string g_cur_phase;
::std::set< ::std::string> g_debug_disable_map;
@@ -83,8 +84,7 @@ void init_debug_list() }
}
}
-bool debug_enabled()
-{
+bool debug_enabled_update() {
if( g_debug_disable_map.count(g_cur_phase) != 0 ) {
return false;
}
@@ -92,6 +92,10 @@ bool debug_enabled() return true;
}
}
+bool debug_enabled()
+{
+ return g_debug_enabled;
+}
::std::ostream& debug_output(int indent, const char* function)
{
return ::std::cout << g_cur_phase << "- " << RepeatLitStr { " ", indent } << function << ": ";
@@ -125,10 +129,12 @@ template <typename Rv, typename Fcn> Rv CompilePhase(const char *name, Fcn f) {
::std::cout << name << ": V V V" << ::std::endl;
g_cur_phase = name;
+ g_debug_enabled = debug_enabled_update();
auto start = clock();
auto rv = f();
auto end = clock();
g_cur_phase = "";
+ g_debug_enabled = debug_enabled_update();
::std::cout <<"(" << ::std::fixed << ::std::setprecision(2) << static_cast<double>(end - start) / static_cast<double>(CLOCKS_PER_SEC) << " s) ";
::std::cout << name << ": DONE";
|