Pass Module by reference instead of shared ptr
This gives a small but noticeable compile time improvement as well as a measurable, albeit not great, reduction in size of the stdlib.
This commit is contained in:
@@ -9,11 +9,11 @@ namespace chaiscript
|
||||
{
|
||||
public:
|
||||
|
||||
static ModulePtr library(ModulePtr m = std::make_shared<Module>())
|
||||
static Module& library(Module& m)
|
||||
{
|
||||
|
||||
m->add(chaiscript::fun([](const std::string &t_str) { return from_json(t_str); }), "from_json");
|
||||
m->add(chaiscript::fun(&json_wrap::to_json), "to_json");
|
||||
m.add(chaiscript::fun([](const std::string &t_str) { return from_json(t_str); }), "from_json");
|
||||
m.add(chaiscript::fun(&json_wrap::to_json), "to_json");
|
||||
|
||||
return m;
|
||||
|
||||
|
||||
@@ -78,10 +78,7 @@ namespace chaiscript
|
||||
t_module.add(chaiscript::constructor<Enum (const Enum &)>(), t_class_name);
|
||||
|
||||
using namespace chaiscript::bootstrap::operators;
|
||||
t_module.add([](){
|
||||
// add some comparison and assignment operators
|
||||
return assign<Enum>(not_equal<Enum>(equal<Enum>()));
|
||||
}());
|
||||
assign<Enum>(not_equal<Enum>(equal<Enum>(t_module)));
|
||||
|
||||
t_module.add(chaiscript::fun([](const Enum &e, const int &i) { return e == i; }), "==");
|
||||
t_module.add(chaiscript::fun([](const int &i, const Enum &e) { return i == e; }), "==");
|
||||
|
||||
Reference in New Issue
Block a user