Fix magic_enum compilation times (#4113)

This commit is contained in:
Piotr Wójcik 2023-02-08 23:02:05 +01:00 committed by GitHub
commit 49b8ccea28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 24 deletions

View file

@ -69,6 +69,7 @@ add_library(
stats.hpp
stats.cpp
stats_enums.hpp
stats_enums.cpp
stream.hpp
threading.hpp
threading.cpp

View file

@ -1,3 +0,0 @@
#define MAGIC_ENUM_RANGE_MIN 0
#define MAGIC_ENUM_RANGE_MAX 256
#include <magic_enum.hpp>

21
nano/lib/stats_enums.cpp Normal file
View file

@ -0,0 +1,21 @@
#include <nano/lib/stats_enums.hpp>
#define MAGIC_ENUM_RANGE_MIN 0
#define MAGIC_ENUM_RANGE_MAX 256
#include <magic_enum.hpp>
std::string_view nano::to_string (nano::stat::type type)
{
return magic_enum::enum_name (type);
}
std::string_view nano::to_string (nano::stat::detail detail)
{
return magic_enum::enum_name (detail);
}
std::string_view nano::to_string (nano::stat::dir dir)
{
return magic_enum::enum_name (dir);
}

View file

@ -1,6 +1,7 @@
#pragma once
#include <nano/lib/magic_enum.hpp>
#include <cstdint>
#include <string_view>
namespace nano::stat
{
@ -277,21 +278,7 @@ enum class dir : uint8_t
namespace nano
{
/** Returns string representation of type */
inline std::string_view to_string (stat::type type)
{
return magic_enum::enum_name (type);
}
/** Returns string representation of detail */
inline std::string_view to_string (stat::detail detail)
{
return magic_enum::enum_name (detail);
}
/** Returns string representation of dir */
inline std::string_view to_string (stat::dir dir)
{
return magic_enum::enum_name (dir);
}
std::string_view to_string (stat::type type);
std::string_view to_string (stat::detail detail);
std::string_view to_string (stat::dir dir);
}

View file

@ -4,8 +4,6 @@
#include <sstream>
using namespace magic_enum::ostream_operators;
/*
* rate_observer::counter
*/
@ -49,7 +47,7 @@ uint64_t nano::test::rate_observer::stat_counter::count ()
std::string nano::test::rate_observer::stat_counter::name ()
{
std::stringstream ss;
ss << type << "::" << detail << "::" << dir;
ss << nano::to_string (type) << "::" << nano::to_string (detail) << "::" << nano::to_string (dir);
return ss.str ();
}