Skip to content

Commit

Permalink
Fix magic_enum compilation times (#4113)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Feb 8, 2023
1 parent 73d08dc commit 49b8cce
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
1 change: 1 addition & 0 deletions nano/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ add_library(
stats.hpp
stats.cpp
stats_enums.hpp
stats_enums.cpp
stream.hpp
threading.hpp
threading.cpp
Expand Down
3 changes: 0 additions & 3 deletions nano/lib/magic_enum.hpp

This file was deleted.

21 changes: 21 additions & 0 deletions nano/lib/stats_enums.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
23 changes: 5 additions & 18 deletions nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <nano/lib/magic_enum.hpp>
#include <cstdint>
#include <string_view>

namespace nano::stat
{
Expand Down Expand Up @@ -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);
}
4 changes: 1 addition & 3 deletions nano/test_common/rate_observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include <sstream>

using namespace magic_enum::ostream_operators;

/*
* rate_observer::counter
*/
Expand Down Expand Up @@ -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 ();
}

Expand Down

0 comments on commit 49b8cce

Please sign in to comment.