Commit 761f690a authored by Marius Wachtler's avatar Marius Wachtler

Reduce number of temporary std::strings

Reduces fannkuch.py runtime on my machine from 25.5 secs to 16.5 secs.
parent b8f40b57
...@@ -372,10 +372,13 @@ void HCBox::giveAttr(const std::string& attr, Box* val) { ...@@ -372,10 +372,13 @@ void HCBox::giveAttr(const std::string& attr, Box* val) {
} }
void HCBox::setattr(const std::string& attr, Box* val, SetattrRewriteArgs *rewrite_args, SetattrRewriteArgs2 *rewrite_args2) { void HCBox::setattr(const std::string& attr, Box* val, SetattrRewriteArgs *rewrite_args, SetattrRewriteArgs2 *rewrite_args2) {
RELEASE_ASSERT(attr != "None" || this == builtins_module, "can't assign to None"); static const std::string none_str("None");
static const std::string getattr_str("__getattr__");
static const std::string getattribute_str("__getattribute__");
bool isgetattr = (attr == "__getattr__" || attr == "__getattribute__"); RELEASE_ASSERT(attr != none_str || this == builtins_module, "can't assign to None");
if (isgetattr && this->cls == type_cls) {
if ((this->cls == type_cls) && (attr == getattr_str || attr == getattribute_str)) {
// Will have to embed the clear in the IC, so just disable the patching for now: // Will have to embed the clear in the IC, so just disable the patching for now:
rewrite_args = NULL; rewrite_args = NULL;
rewrite_args2 = NULL; rewrite_args2 = NULL;
......
...@@ -246,10 +246,14 @@ extern "C" { ...@@ -246,10 +246,14 @@ extern "C" {
} }
extern "C" Box* createSlice(Box* start, Box* stop, Box* step) { extern "C" Box* createSlice(Box* start, Box* stop, Box* step) {
static const std::string start_str("start");
static const std::string stop_str("stop");
static const std::string step_str("step");
BoxedSlice *rtn = new BoxedSlice(start, stop, step); BoxedSlice *rtn = new BoxedSlice(start, stop, step);
rtn->setattr("start", start, NULL, NULL); rtn->setattr(start_str, start, NULL, NULL);
rtn->setattr("stop", stop, NULL, NULL); rtn->setattr(stop_str, stop, NULL, NULL);
rtn->setattr("step", step, NULL, NULL); rtn->setattr(step_str, step, NULL, NULL);
return rtn; return rtn;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment