Skip to content

Commit ee625d6

Browse files
committed
tweaking conditional structure in var_stats
1 parent 2b571a3 commit ee625d6

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

bfun.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,16 @@ bool var_stats(bfun* b, int* count, int* diff, int* is_binate) {
171171
// yuck
172172
for(cube* c = b->begin; c != NULL; c = c->next) {
173173
for (int i = 1; i <= b->var_count; i++) {
174-
if (c->values[i] == t) {
175-
count[i]++;
176-
if (diff[i] < 0) {
177-
is_binate[i] = true;
178-
found_binate = true;
179-
}
180-
diff[i] ++;
181-
} else if (c->values[i] == f) {
174+
int sign;
175+
if (c->values[i] == t) sign = 1;
176+
else if (c->values[i] == f) sign = -1;
177+
if(diff[i] * sign < 0) {
178+
is_binate[i] = true;
179+
found_binate = true;
180+
}
181+
if (c->values[i] == t || c->values[i] == f) {
182182
count[i]++;
183-
if (diff[i] > 0) {
184-
is_binate[i] = true;
185-
found_binate = true;
186-
}
187-
diff[i]--;
183+
diff[i]+=sign;
188184
}
189185

190186
}

0 commit comments

Comments
 (0)