Skip to content

Commit 4e53ee8

Browse files
committed
Enable inlining of Logger::enabled().
This should help with performance of previous commit.
1 parent 2b6dbb0 commit 4e53ee8

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

gen/logger.cpp

+3-13
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ void Stream::writeValue(std::ostream& OS, const llvm::Value& V) {
5656
namespace Logger
5757
{
5858
static std::string indent_str;
59+
bool _enabled;
5960

60-
llvm::cl::opt<bool> _enabled("vv",
61+
static llvm::cl::opt<bool, true> enabledopt("vv",
6162
llvm::cl::desc("Print front-end/glue code debug log"),
63+
llvm::cl::location(_enabled),
6264
llvm::cl::ZeroOrMore);
6365

6466
void indent()
@@ -126,18 +128,6 @@ namespace Logger
126128
va_end(va);
127129
}
128130
}
129-
void enable()
130-
{
131-
_enabled = true;
132-
}
133-
void disable()
134-
{
135-
_enabled = false;
136-
}
137-
bool enabled()
138-
{
139-
return _enabled;
140-
}
141131
void attention(Loc loc, const char* fmt,...)
142132
{
143133
va_list va;

gen/logger.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,16 @@ class Stream {
9595

9696
namespace Logger
9797
{
98+
extern bool _enabled;
99+
98100
void indent();
99101
void undent();
100102
Stream cout();
101103
void println(const char* fmt, ...) IS_PRINTF(1);
102104
void print(const char* fmt, ...) IS_PRINTF(1);
103-
void enable();
104-
void disable();
105-
bool enabled();
105+
inline void enable() { _enabled = true; }
106+
inline void disable() { _enabled = false; }
107+
inline bool enabled() { return _enabled; }
106108

107109
void attention(Loc loc, const char* fmt, ...) IS_PRINTF(2);
108110

0 commit comments

Comments
 (0)