Commit 1206cf29 authored by Marius Wachtler's avatar Marius Wachtler

microoptimizations

parent 85a1c69b
......@@ -515,9 +515,6 @@ Box* setUnion(BoxedSet* self, BoxedTuple* args) {
BoxedSet* rtn = makeNewSet(self->cls, self);
AUTO_DECREF(rtn);
for (auto&& p : self->s)
_setAdd(rtn, p);
for (auto container : args->pyElements()) {
AUTO_DECREF(container);
for (auto elt : container->pyElements()) {
......
......@@ -265,7 +265,7 @@ Box* tupleRepr(Box* _t) {
BoxedTuple* t = (BoxedTuple*)_t;
int n;
std::vector<char> chars;
llvm::SmallVector<char, 128> chars;
int status = Py_ReprEnter((PyObject*)t);
n = t->size();
if (n == 0) {
......@@ -427,7 +427,7 @@ extern "C" Box* tupleNew(Box* _cls, BoxedTuple* args, BoxedDict* kwargs) {
return r;
}
std::vector<Box*> elts;
llvm::SmallVector<Box*, 16> elts;
try {
for (auto e : elements->pyElements())
elts.push_back(e);
......@@ -437,10 +437,16 @@ extern "C" Box* tupleNew(Box* _cls, BoxedTuple* args, BoxedDict* kwargs) {
throw e;
}
auto rtn = BoxedTuple::create(elts.size(), cls);
memcpy(&rtn->elts[0], &elts[0], elts.size() * sizeof(Box*));
if (elts.empty()) {
if (cls == tuple_cls)
return incref(EmptyTuple);
return BoxedTuple::create(0, cls);
} else {
auto rtn = BoxedTuple::create(elts.size(), cls);
memcpy(&rtn->elts[0], &elts[0], elts.size() * sizeof(Box*));
return rtn;
}
return rtn;
} else {
if (cls == tuple_cls)
return incref(EmptyTuple);
......
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