From 8014dbe6e0e6f87b29d2e761f0ac1a0fe4d7582f Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 20 Nov 2020 21:36:48 +0100 Subject: [PATCH] Misc simplifications. --- src/mc/ModelChecker.cpp | 13 ++++++------- src/mc/inspect/mc_dwarf.cpp | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/mc/ModelChecker.cpp b/src/mc/ModelChecker.cpp index 4ae8982abb..30e20e665a 100644 --- a/src/mc/ModelChecker.cpp +++ b/src/mc/ModelChecker.cpp @@ -84,19 +84,18 @@ void ModelChecker::start() #endif } -static const std::pair ignored_local_variables[] = { - std::pair{ "e", "*" }, - std::pair{ "_log_ev", "*" }, +static constexpr auto ignored_local_variables = { + std::make_pair("e", "*"), + std::make_pair("_log_ev", "*"), - /* Ignore local variable about time used for tracing */ - std::pair{ "start_time", "*" }, + /* Ignore local variable about time used for tracing */ + std::make_pair("start_time", "*"), }; void ModelChecker::setup_ignore() { const RemoteSimulation& process = this->get_remote_simulation(); - for (std::pair const& var : - ignored_local_variables) + for (auto const& var : ignored_local_variables) process.ignore_local_variable(var.first, var.second); /* Static variable used for tracing */ diff --git a/src/mc/inspect/mc_dwarf.cpp b/src/mc/inspect/mc_dwarf.cpp index fee66d8e1f..83444e45b6 100644 --- a/src/mc/inspect/mc_dwarf.cpp +++ b/src/mc/inspect/mc_dwarf.cpp @@ -15,6 +15,8 @@ #include "src/mc/mc_private.hpp" #include "src/mc/remote/RemoteSimulation.hpp" +#include +#include #include #include #include @@ -961,11 +963,11 @@ static std::vector get_build_id(Elf* elf) return std::vector(); } -static char hexdigits[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - /** Binary data to hexadecimal */ static inline std::array to_hex(std::uint8_t byte) { + constexpr std::array hexdigits{ + {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}}; // Horrid double braces! // Apparently, this is needed in C++11 (not in C++14). return {{hexdigits[byte >> 4], hexdigits[byte & 0xF]}}; @@ -976,11 +978,8 @@ static std::string to_hex(const char* data, std::size_t count) { std::string res; res.resize(2 * count); - for (std::size_t i = 0; i < count; i++) { - std::array hex_byte = to_hex(data[i]); - for (int j = 0; j < 2; ++j) - res[2 * i + j] = hex_byte[j]; - } + for (std::size_t i = 0; i < count; i++) + std::copy_n(cbegin(to_hex(data[i])), 2, &res[2 * i]); return res; } -- 2.20.1