Fix magic_enum compilation times (#4113)
This commit is contained in:
		
					parent
					
						
							
								73d08dcb50
							
						
					
				
			
			
				commit
				
					
						49b8ccea28
					
				
			
		
					 5 changed files with 28 additions and 24 deletions
				
			
		|  | @ -69,6 +69,7 @@ add_library( | ||||||
|   stats.hpp |   stats.hpp | ||||||
|   stats.cpp |   stats.cpp | ||||||
|   stats_enums.hpp |   stats_enums.hpp | ||||||
|  |   stats_enums.cpp | ||||||
|   stream.hpp |   stream.hpp | ||||||
|   threading.hpp |   threading.hpp | ||||||
|   threading.cpp |   threading.cpp | ||||||
|  |  | ||||||
|  | @ -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
									
								
							
							
						
						
									
										21
									
								
								nano/lib/stats_enums.cpp
									
										
									
									
									
										Normal 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); | ||||||
|  | } | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <nano/lib/magic_enum.hpp> | #include <cstdint> | ||||||
|  | #include <string_view> | ||||||
| 
 | 
 | ||||||
| namespace nano::stat | namespace nano::stat | ||||||
| { | { | ||||||
|  | @ -277,21 +278,7 @@ enum class dir : uint8_t | ||||||
| 
 | 
 | ||||||
| namespace nano | namespace nano | ||||||
| { | { | ||||||
| /** Returns string representation of type */ | std::string_view to_string (stat::type type); | ||||||
| inline std::string_view to_string (stat::type type) | std::string_view to_string (stat::detail detail); | ||||||
| { | std::string_view to_string (stat::dir dir); | ||||||
| 	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); |  | ||||||
| } |  | ||||||
| } | } | ||||||
|  | @ -4,8 +4,6 @@ | ||||||
| 
 | 
 | ||||||
| #include <sstream> | #include <sstream> | ||||||
| 
 | 
 | ||||||
| using namespace magic_enum::ostream_operators; |  | ||||||
| 
 |  | ||||||
| /*
 | /*
 | ||||||
|  * rate_observer::counter |  * 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::string nano::test::rate_observer::stat_counter::name () | ||||||
| { | { | ||||||
| 	std::stringstream ss; | 	std::stringstream ss; | ||||||
| 	ss << type << "::" << detail << "::" << dir; | 	ss << nano::to_string (type) << "::" << nano::to_string (detail) << "::" << nano::to_string (dir); | ||||||
| 	return ss.str (); | 	return ss.str (); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Piotr Wójcik
				Piotr Wójcik