Skip to content

Commit d95bb5c

Browse files
committed
Allow coalesce_up to assert can_coalesce_up.
1 parent e1b5d76 commit d95bb5c

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

datareps1/solutions/flapmaps5.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ bool can_coalesce_up(flapmap_iter it) {
2929
}
3030

3131
void coalesce_up(flapmap_iter it) {
32-
if (can_coalesce_up(it)) {
33-
auto next = it;
34-
++next;
35-
it->second.duration += next->second.duration;
36-
it->second.flapcount += next->second.flapcount;
37-
flapmap.erase(next);
38-
}
32+
assert(can_coalesce_up(it));
33+
auto next = it;
34+
++next;
35+
it->second.duration += next->second.duration;
36+
it->second.flapcount += next->second.flapcount;
37+
flapmap.erase(next);
3938
}
4039

4140
bool can_coalesce_down(flapmap_iter it) {

datareps1/solutions/flapmaps6.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ bool can_coalesce_up(flapmap_iter it) {
2929
}
3030

3131
void coalesce_up(flapmap_iter it) {
32-
if (can_coalesce_up(it)) {
33-
auto next = it;
34-
++next;
35-
it->second.duration += next->second.duration;
36-
it->second.flapcount += next->second.flapcount;
37-
flapmap.erase(next);
38-
}
32+
assert(can_coalesce_up(it));
33+
auto next = it;
34+
++next;
35+
it->second.duration += next->second.duration;
36+
it->second.flapcount += next->second.flapcount;
37+
flapmap.erase(next);
3938
}
4039

4140
bool can_coalesce_down(flapmap_iter it) {

0 commit comments

Comments
 (0)