From 7b4f5efee4484b856652ac9c86409cb6dee1941b Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 19 Oct 2016 14:15:18 +0800 Subject: main - Cache debug enabled result --- src/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') 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 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(end - start) / static_cast(CLOCKS_PER_SEC) << " s) "; ::std::cout << name << ": DONE"; -- cgit v1.2.3