From c4633436ba37324bdbf4d9e1ce7d2863b453703a Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 20 Jun 2015 07:13:54 -0600 Subject: [PATCH] Avoid placeholder lookup cost --- include/chaiscript/dispatchkit/dispatchkit.hpp | 11 +---------- include/chaiscript/language/chaiscript_eval.hpp | 11 +++++------ 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index d752856..676b5f1 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -408,8 +408,7 @@ namespace chaiscript }; Dispatch_Engine() - : m_stack_holder(this), - m_place_holder(std::make_shared()) + : m_stack_holder(this) { } @@ -572,12 +571,6 @@ namespace chaiscript /// ensure that it is always in scope. Boxed_Value get_object(const std::string &name) const { - // Is it a placeholder object? - if (name == "_") - { - return m_place_holder; - } - auto &stack = get_stack_data(); // Is it in the stack? @@ -1345,8 +1338,6 @@ namespace chaiscript State m_state; - - Boxed_Value m_place_holder; }; } } diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 8d1f6e1..2b8b601 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -170,15 +170,14 @@ namespace chaiscript { if (t_text == "true") { return const_var(true); - } - else if (t_text == "false") { + } else if (t_text == "false") { return const_var(false); - } - else if (t_text == "Infinity") { + } else if (t_text == "Infinity") { return const_var(std::numeric_limits::infinity()); - } - else if (t_text == "NaN") { + } else if (t_text == "NaN") { return const_var(std::numeric_limits::quiet_NaN()); + } else if (t_text == "_") { + return Boxed_Value(std::make_shared()); } else { return Boxed_Value(); }