diff --git a/include/chaiscript/language/chaiscript_algebraic.hpp b/include/chaiscript/language/chaiscript_algebraic.hpp index 5cf132dd..3e5675aa 100644 --- a/include/chaiscript/language/chaiscript_algebraic.hpp +++ b/include/chaiscript/language/chaiscript_algebraic.hpp @@ -55,14 +55,14 @@ namespace chaiscript return opers[static_cast(t_oper)]; } - static Opers to_operator(const std::string &t_str, bool t_is_unary = false) noexcept + constexpr static Opers to_operator(const char * const t_str, bool t_is_unary = false) noexcept { #ifdef CHAISCRIPT_MSVC #pragma warning(push) #pragma warning(disable : 4307) #endif - const auto op_hash = utility::fnv1a_32(t_str.c_str()); + const auto op_hash = utility::fnv1a_32(t_str); switch (op_hash) { case utility::fnv1a_32("=="): { return Opers::equals; } case utility::fnv1a_32("<"): { return Opers::less_than; } diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 23557ca1..6716dd9e 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -159,7 +159,7 @@ namespace chaiscript struct Fold_Right_Binary_Operator_AST_Node : AST_Node_Impl { Fold_Right_Binary_Operator_AST_Node(const std::string &t_oper, Parse_Location t_loc, std::vector> t_children, Boxed_Value t_rhs) : AST_Node_Impl(t_oper, AST_Node_Type::Binary, std::move(t_loc), std::move(t_children)), - m_oper(Operators::to_operator(t_oper)), + m_oper(Operators::to_operator(t_oper.c_str())), m_rhs(std::move(t_rhs)) { } @@ -204,7 +204,7 @@ namespace chaiscript struct Binary_Operator_AST_Node : AST_Node_Impl { Binary_Operator_AST_Node(const std::string &t_oper, Parse_Location t_loc, std::vector> t_children) : AST_Node_Impl(t_oper, AST_Node_Type::Binary, std::move(t_loc), std::move(t_children)), - m_oper(Operators::to_operator(t_oper)) + m_oper(Operators::to_operator(t_oper.c_str())) { } Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override { @@ -420,7 +420,7 @@ namespace chaiscript struct Equation_AST_Node final : AST_Node_Impl { Equation_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector> t_children) : AST_Node_Impl(std::move(t_ast_node_text), AST_Node_Type::Equation, std::move(t_loc), std::move(t_children)), - m_oper(Operators::to_operator(this->text)) + m_oper(Operators::to_operator(this->text.c_str())) { assert(this->children.size() == 2); } @@ -1162,7 +1162,7 @@ namespace chaiscript struct Prefix_AST_Node final : AST_Node_Impl { Prefix_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector> t_children) : AST_Node_Impl(std::move(t_ast_node_text), AST_Node_Type::Prefix, std::move(t_loc), std::move(t_children)), - m_oper(Operators::to_operator(this->text, true)) + m_oper(Operators::to_operator(this->text.c_str(), true)) { } Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{ diff --git a/include/chaiscript/language/chaiscript_optimizer.hpp b/include/chaiscript/language/chaiscript_optimizer.hpp index 3df867f1..877cb4a7 100644 --- a/include/chaiscript/language/chaiscript_optimizer.hpp +++ b/include/chaiscript/language/chaiscript_optimizer.hpp @@ -241,7 +241,7 @@ namespace chaiscript { { try { const auto &oper = node->text; - const auto parsed = Operators::to_operator(oper); + const auto parsed = Operators::to_operator(oper.c_str()); if (parsed != Operators::Opers::invalid) { const auto rhs = dynamic_cast *>(node->children[1].get())->m_value; if (rhs.get_type_info().is_arithmetic()) { @@ -268,7 +268,7 @@ namespace chaiscript { { try { const auto &oper = node->text; - const auto parsed = Operators::to_operator(oper, true); + const auto parsed = Operators::to_operator(oper.c_str(), true); const auto lhs = dynamic_cast *>(node->children[0].get())->m_value; const auto match = oper + node->children[0]->text; @@ -308,7 +308,7 @@ namespace chaiscript { { try { const auto &oper = node->text; - const auto parsed = Operators::to_operator(oper); + const auto parsed = Operators::to_operator(oper.c_str()); if (parsed != Operators::Opers::invalid) { const auto lhs = dynamic_cast &>(*node->children[0]).m_value; const auto rhs = dynamic_cast &>(*node->children[1]).m_value;