summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1ac398a)
Avoiding redundant declarations and division by zero.
double sum_cur = 0.0;
double sum_tot = 0.0;
for (i = 0; i<ct->no_children; i++){
double sum_cur = 0.0;
double sum_tot = 0.0;
for (i = 0; i<ct->no_children; i++){
- double nratio, cur, tot;
rset_pos(mrfd->items[i].fd, &cur, &tot);
yaz_log(log_level, "r_pos: %d %0.1f %0.1f", i, cur,tot);
rset_pos(mrfd->items[i].fd, &cur, &tot);
yaz_log(log_level, "r_pos: %d %0.1f %0.1f", i, cur,tot);
- if (nratio > ratio)
- ratio = nratio;
+ if (tot > 0.0)
+ {
+ double nratio = cur / tot;
+ if (nratio > ratio)
+ ratio = nratio;
+ }
+ if (!and_op && sum_tot > 0.0)
ratio = sum_cur / sum_tot;
if (ratio == 0.0 || ratio == 1.0) { /* nothing there */
*current = 0;
ratio = sum_cur / sum_tot;
if (ratio == 0.0 || ratio == 1.0) { /* nothing there */
*current = 0;