Commit d27c3700 authored by Bob Fang's avatar Bob Fang

fix bug #171: if identity_eq is true then we do not need to call compareInternal

parent 1a4c2d2c
......@@ -395,9 +395,13 @@ Box* listContains(BoxedList* self, Box* elt) {
int size = self->size;
for (int i = 0; i < size; i++) {
Box* e = self->elts->elts[i];
Box* cmp = compareInternal(e, elt, AST_TYPE::Eq, NULL);
bool identity_eq = e == elt;
bool b = nonzero(cmp) || identity_eq;
if(identity_eq)
return True;
Box* cmp = compareInternal(e, elt, AST_TYPE::Eq, NULL);
bool b = nonzero(cmp);
if (b)
return True;
}
......@@ -518,9 +522,12 @@ Box* _listCmp(BoxedList* lhs, BoxedList* rhs, AST_TYPE::AST_TYPE op_type) {
int n = std::min(lsz, rsz);
for (int i = 0; i < n; i++) {
Box* is_eq = compareInternal(lhs->elts->elts[i], rhs->elts->elts[i], AST_TYPE::Eq, NULL);
bool identity_eq = lhs->elts->elts[i] == rhs->elts->elts[i];
bool bis_eq = nonzero(is_eq) || identity_eq;
if(identity_eq)
continue;
Box* is_eq = compareInternal(lhs->elts->elts[i], rhs->elts->elts[i], AST_TYPE::Eq, NULL);
bool bis_eq = nonzero(is_eq);
if (bis_eq)
continue;
......
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