Avoid placeholder lookup cost
This commit is contained in:
@@ -408,8 +408,7 @@ namespace chaiscript
|
|||||||
};
|
};
|
||||||
|
|
||||||
Dispatch_Engine()
|
Dispatch_Engine()
|
||||||
: m_stack_holder(this),
|
: m_stack_holder(this)
|
||||||
m_place_holder(std::make_shared<dispatch::Placeholder_Object>())
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,12 +571,6 @@ namespace chaiscript
|
|||||||
/// ensure that it is always in scope.
|
/// ensure that it is always in scope.
|
||||||
Boxed_Value get_object(const std::string &name) const
|
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();
|
auto &stack = get_stack_data();
|
||||||
|
|
||||||
// Is it in the stack?
|
// Is it in the stack?
|
||||||
@@ -1345,8 +1338,6 @@ namespace chaiscript
|
|||||||
|
|
||||||
|
|
||||||
State m_state;
|
State m_state;
|
||||||
|
|
||||||
Boxed_Value m_place_holder;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -170,15 +170,14 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
if (t_text == "true") {
|
if (t_text == "true") {
|
||||||
return const_var(true);
|
return const_var(true);
|
||||||
}
|
} else if (t_text == "false") {
|
||||||
else if (t_text == "false") {
|
|
||||||
return const_var(false);
|
return const_var(false);
|
||||||
}
|
} else if (t_text == "Infinity") {
|
||||||
else if (t_text == "Infinity") {
|
|
||||||
return const_var(std::numeric_limits<double>::infinity());
|
return const_var(std::numeric_limits<double>::infinity());
|
||||||
}
|
} else if (t_text == "NaN") {
|
||||||
else if (t_text == "NaN") {
|
|
||||||
return const_var(std::numeric_limits<double>::quiet_NaN());
|
return const_var(std::numeric_limits<double>::quiet_NaN());
|
||||||
|
} else if (t_text == "_") {
|
||||||
|
return Boxed_Value(std::make_shared<dispatch::Placeholder_Object>());
|
||||||
} else {
|
} else {
|
||||||
return Boxed_Value();
|
return Boxed_Value();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user