From 592ee124cbd33152980d3c869af16b606746a7e6 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 31 Jan 2022 20:42:17 +0100 Subject: [PATCH] Manager: Do not print debugging output on release mode --- src/main.cpp | 6 +++++- src/util/argparser.cpp | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 4949103..fc937af 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,7 +47,9 @@ int main(int argc, const char* argv[]) return 1; } +#ifndef NDEBUG Util::Timer t; +#endif Config::the().setVerbose(verbose); @@ -103,7 +105,9 @@ int main(int argc, const char* argv[]) // TODO open manpage } - printf("%fms\n", t.elapsedNanoseconds() / 1000000.0); +#ifndef NDEBUG + printf("%fms\n", t.elapsedNanoseconds() / 1000000.0); +#endif return 0; } diff --git a/src/util/argparser.cpp b/src/util/argparser.cpp index 27f78ad..5649dec 100644 --- a/src/util/argparser.cpp +++ b/src/util/argparser.cpp @@ -1,3 +1,9 @@ +/* + * Copyright (C) 2021-2022 Riyyi + * + * SPDX-License-Identifier: MIT + */ + #include // find_if #include // size_t #include // printf @@ -75,13 +81,18 @@ bool ArgParser::parseShortOption(std::string_view option, std::string_view next) { bool result = true; +#ifndef NDEBUG printf("Parsing short option: '%s'\n", option.data()); +#endif char c; std::string_view value; for (size_t i = 0; i < option.size(); ++i) { c = option.at(i); + +#ifndef NDEBUG printf("short '%c'\n", c); +#endif auto foundOption = std::find_if(m_options.begin(), m_options.end(), [&c](Option& it) -> bool { return it.shortName == c; @@ -263,7 +274,10 @@ bool ArgParser::parse(int argc, const char* argv[]) std::string_view argument; std::string_view next; for (; m_optionIndex < (size_t)argc; ++m_optionIndex) { + +#ifndef NDEBUG printf("argv[%zu]: %s\n", m_optionIndex, argv[m_optionIndex]); +#endif // Get the current and next parameter argument = argv[m_optionIndex];