replace explicit loops with foldr
This commit is contained in:
parent
12b43b274b
commit
fa6e3b49bf
@ -1369,19 +1369,14 @@ pub fn compile_submatch(bcx: block,
|
|||||||
PointerCast(bcx, val, T_opaque_enum_ptr(ccx));
|
PointerCast(bcx, val, T_opaque_enum_ptr(ccx));
|
||||||
let discrimptr = GEPi(bcx, enumptr, [0u, 0u]);
|
let discrimptr = GEPi(bcx, enumptr, [0u, 0u]);
|
||||||
|
|
||||||
let mut min_discrim = variants[0].disr_val;
|
|
||||||
for uint::range(1, variants.len()) |idx| {
|
|
||||||
if variants[idx].disr_val < min_discrim {
|
|
||||||
min_discrim = variants[idx].disr_val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut max_discrim = variants[0].disr_val;
|
assert variants.len() > 1;
|
||||||
for uint::range(1, variants.len()) |idx| {
|
let min_discrim = do variants.foldr(0) |&x, y| {
|
||||||
if variants[idx].disr_val > max_discrim {
|
int::min(x.disr_val, y)
|
||||||
max_discrim = variants[idx].disr_val;
|
};
|
||||||
}
|
let max_discrim = do variants.foldr(0) |&x, y| {
|
||||||
}
|
int::max(x.disr_val, y)
|
||||||
|
};
|
||||||
|
|
||||||
test_val = LoadRangeAssert(bcx, discrimptr,
|
test_val = LoadRangeAssert(bcx, discrimptr,
|
||||||
min_discrim as c_ulonglong,
|
min_discrim as c_ulonglong,
|
||||||
|
Loading…
Reference in New Issue
Block a user