Commit 0cf0c7fe authored by Marius Wachtler's avatar Marius Wachtler

setNew2: use iterator class

overlooked this one in the previous commit
parent 08977a8d
......@@ -72,24 +72,11 @@ Box* setNew1(Box* cls) {
Box* setNew2(Box* cls, Box* container) {
assert(cls == set_cls);
static std::string _iter("__iter__");
static std::string _hasnext("__hasnext__");
static std::string _next("next");
Box* iter = callattr(container, &_iter, true, 0, NULL, NULL, NULL, NULL);
Box* rtn = new BoxedSet();
while (true) {
Box* hasnext = callattr(iter, &_hasnext, true, 0, NULL, NULL, NULL, NULL);
bool hasnext_bool = nonzero(hasnext);
if (!hasnext_bool)
break;
Box* next = callattr(iter, &_next, true, 0, NULL, NULL, NULL, NULL);
setAdd2(rtn, next);
for (Box* e : *container) {
setAdd2(rtn, e);
}
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