Speed up to_string performance by relying on C++ versions
Addresses #134, fixing issues introduced by #132
This commit is contained in:
@@ -472,8 +472,8 @@ namespace chaiscript
|
|||||||
operators::assign<bool>(m);
|
operators::assign<bool>(m);
|
||||||
operators::equal<bool>(m);
|
operators::equal<bool>(m);
|
||||||
|
|
||||||
m->add(fun(&to_string<const std::string &>), "internal_to_string");
|
m->add(fun(&to_string<const std::string &>), "to_string");
|
||||||
m->add(fun(&Bootstrap::bool_to_string), "internal_to_string");
|
m->add(fun(&Bootstrap::bool_to_string), "to_string");
|
||||||
m->add(fun(&unknown_assign), "=");
|
m->add(fun(&unknown_assign), "=");
|
||||||
m->add(fun(&throw_exception), "throw");
|
m->add(fun(&throw_exception), "throw");
|
||||||
m->add(fun(&what), "what");
|
m->add(fun(&what), "what");
|
||||||
@@ -553,7 +553,7 @@ namespace chaiscript
|
|||||||
{fun(&AST_Node::filename), "filename"},
|
{fun(&AST_Node::filename), "filename"},
|
||||||
{fun(&AST_Node::start), "start"},
|
{fun(&AST_Node::start), "start"},
|
||||||
{fun(&AST_Node::end), "end"},
|
{fun(&AST_Node::end), "end"},
|
||||||
{fun(&AST_Node::internal_to_string), "internal_to_string"},
|
{fun(&AST_Node::to_string), "to_string"},
|
||||||
{fun(std::function<std::vector<Boxed_Value> (const chaiscript::AST_Node &t_node)>([](const chaiscript::AST_Node &t_node) {
|
{fun(std::function<std::vector<Boxed_Value> (const chaiscript::AST_Node &t_node)>([](const chaiscript::AST_Node &t_node) {
|
||||||
std::vector<Boxed_Value> retval;
|
std::vector<Boxed_Value> retval;
|
||||||
std::transform(t_node.children.begin(), t_node.children.end(),
|
std::transform(t_node.children.begin(), t_node.children.end(),
|
||||||
|
@@ -430,17 +430,13 @@ namespace chaiscript
|
|||||||
|
|
||||||
oss << t_prepend << "(" << ast_node_type_to_string(this->identifier) << ") "
|
oss << t_prepend << "(" << ast_node_type_to_string(this->identifier) << ") "
|
||||||
<< this->text << " : " << this->start.line << ", " << this->start.column << std::endl;
|
<< this->text << " : " << this->start.line << ", " << this->start.column << std::endl;
|
||||||
|
|
||||||
for (size_t j = 0; j < this->children.size(); ++j) {
|
for (size_t j = 0; j < this->children.size(); ++j) {
|
||||||
oss << this->children[j]->to_string(t_prepend + " ");
|
oss << this->children[j]->to_string(t_prepend + " ");
|
||||||
}
|
}
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string internal_to_string() {
|
|
||||||
return to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_e)
|
Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_e)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@@ -56,11 +56,6 @@ def to_string(x) : call_exists(range, x) && !x.is_type("string"){
|
|||||||
"[" + x.join(", ") + "]";
|
"[" + x.join(", ") + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Basic to_string function
|
|
||||||
def to_string(x) {
|
|
||||||
internal_to_string(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Prints to console with no carriage return
|
# Prints to console with no carriage return
|
||||||
def puts(x) {
|
def puts(x) {
|
||||||
print_string(x.to_string());
|
print_string(x.to_string());
|
||||||
|
Reference in New Issue
Block a user