From ff70341af243adfa3b300f7eccef09537721dc1d Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 24 Aug 2017 21:14:05 -0600 Subject: [PATCH] Avoid conversions to string_view, 2% perf savings --- include/chaiscript/dispatchkit/dispatchkit.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index 3d6eba2a..ccaa03c0 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -437,9 +437,19 @@ namespace chaiscript /// of the object stack, functions and registered types. class Dispatch_Engine { + struct str_less { + bool operator()(const std::string &t_lhs, const std::string &t_rhs) const noexcept { + return t_lhs < t_rhs; + } + template + bool operator()(const LHS &t_lhs, const RHS &t_rhs) const noexcept { + return std::lexicographical_compare(t_lhs.begin(), t_lhs.end(), t_rhs.begin(), t_rhs.end()); + } + struct is_transparent{}; + }; public: - typedef std::map> Type_Name_Map; + typedef std::map Type_Name_Map; typedef std::vector> Scope; typedef Stack_Holder::StackData StackData; @@ -448,7 +458,7 @@ namespace chaiscript std::vector>>> m_functions; std::vector> m_function_objects; std::vector> m_boxed_functions; - std::map> m_global_objects; + std::map m_global_objects; Type_Name_Map m_types; };