diff --git a/include/fxos/util/Addressable.h b/include/fxos/util/Addressable.h index 7a61f8f..c167905 100644 --- a/include/fxos/util/Addressable.h +++ b/include/fxos/util/Addressable.h @@ -24,17 +24,17 @@ template struct Addressable { - /* Value */ - T value; - /* Original virtual address */ - uint32_t address; + /* Value */ + T value; + /* Original virtual address */ + uint32_t address; - Addressable() = default; - Addressable(T value): value(value), address(-1) {} - Addressable(uint32_t addr, T value): value(value), address(addr) {} + Addressable() = default; + Addressable(T value): value(value), address(-1) {} + Addressable(uint32_t addr, T value): value(value), address(addr) {} - /* Implicitly decay to the base type */ - operator T () const { return value; } + /* Implicitly decay to the base type */ + operator T () const { return value; } }; #endif /* FXOS_UTIL_ADDRESSABLE_H */ diff --git a/include/fxos/util/format.h b/include/fxos/util/format.h index 960cdec..df91f49 100644 --- a/include/fxos/util/format.h +++ b/include/fxos/util/format.h @@ -21,34 +21,34 @@ /* Format a string with printf() syntax */ template -std::string format_do(std::string const &format, Args && ... args) +std::string _format_do(std::string const &format, Args && ... args) { - /* Reserve space for snprintf() to put its NUL */ - size_t size = snprintf(nullptr, 0, format.c_str(), args ...) + 1; + /* Reserve space for snprintf() to put its NUL */ + size_t size = snprintf(nullptr, 0, format.c_str(), args ...) + 1; - std::unique_ptr buf(new char[size]); - snprintf(buf.get(), size, format.c_str(), args ...); + std::unique_ptr buf(new char[size]); + snprintf(buf.get(), size, format.c_str(), args ...); - /* Remove the NUL from the string */ - return std::string(buf.get(), buf.get() + size - 1); + /* Remove the NUL from the string */ + return std::string(buf.get(), buf.get() + size - 1); } /* Convert std::string to char * when printing (by @Zitrax on Github) */ template -auto format_convert(T&& t) +auto _format_convert(T&& t) { - if constexpr(std::is_same>, - std::string>::value) - return std::forward(t).c_str(); - else - return std::forward(t); + if constexpr(std::is_same>, + std::string>::value) + return std::forward(t).c_str(); + else + return std::forward(t); } /* String formatting with std::string support in %s */ template std::string format(std::string const &format, Args && ... args) { - return format_do(format, format_convert(std::forward(args))...); + return _format_do(format, _format_convert(std::forward(args))...); } #endif /* FXOS_UTIL_FORMAT_H */ diff --git a/lib/util/Timer.cpp b/lib/util/Timer.cpp index 1b92f39..a634fe0 100644 --- a/lib/util/Timer.cpp +++ b/lib/util/Timer.cpp @@ -9,45 +9,45 @@ #include Timer::Timer(): - time_ns {0}, running {false}, start_time {}, depth {0} + time_ns {0}, running {false}, start_time {}, depth {0} { } void Timer::start(void) { - if(this->depth++ == 0) { - this->running = true; - clock_gettime(CLOCK_REALTIME, &this->start_time); - } + if(this->depth++ == 0) { + this->running = true; + clock_gettime(CLOCK_REALTIME, &this->start_time); + } } void Timer::stop(void) { - if(--this->depth == 0) { - this->running = false; - struct timespec end; - clock_gettime(CLOCK_REALTIME, &end); + if(--this->depth == 0) { + this->running = false; + struct timespec end; + clock_gettime(CLOCK_REALTIME, &end); - this->time_ns += 1000000000 * (end.tv_sec - this->start_time.tv_sec) - + (end.tv_nsec - this->start_time.tv_nsec); + this->time_ns += 1000000000 * (end.tv_sec - this->start_time.tv_sec) + + (end.tv_nsec - this->start_time.tv_nsec); - this->start_time.tv_sec = 0; - this->start_time.tv_nsec = 0; - } + this->start_time.tv_sec = 0; + this->start_time.tv_nsec = 0; + } } std::string Timer::format_time(uint64_t time_ns) { - if(time_ns < 2000) return format("%lld ns", time_ns); - time_ns /= 1000; - if(time_ns < 2000) return format("%lld us", time_ns); - time_ns /= 1000; - if(time_ns < 2000) return format("%lld ms", time_ns); - time_ns /= 1000; - return format("%lld s", time_ns); + if(time_ns < 2000) return format("%lld ns", time_ns); + time_ns /= 1000; + if(time_ns < 2000) return format("%lld us", time_ns); + time_ns /= 1000; + if(time_ns < 2000) return format("%lld ms", time_ns); + time_ns /= 1000; + return format("%lld s", time_ns); } std::string Timer::format_time() const { - return Timer::format_time(this->time_ns); + return Timer::format_time(this->time_ns); }