diff --git a/era/era_invalidate.cc b/era/era_invalidate.cc index 9e63578..42bf67b 100644 --- a/era/era_invalidate.cc +++ b/era/era_invalidate.cc @@ -94,6 +94,20 @@ namespace { //-------------------------------- + template + pair next_run(Iterator &it, Iterator end) { + uint32_t b, e; + + b = *it++; + e = b + 1; + while (it != end && *it == e) { + e++; + it++; + } + + return make_pair(b, e); + } + void emit_blocks(ostream &out, set const &blocks) { indented_stream o(out); @@ -102,10 +116,17 @@ namespace { o.inc(); { - set::const_iterator it; - for (it = blocks.begin(); it != blocks.end(); ++it) { + set::const_iterator it = blocks.begin(); + while (it != blocks.end()) { o.indent(); - o << "" << endl; + + pair range = next_run(it, blocks.end()); + if (range.second - range.first == 1) + o << "" << endl; + + else + o << "" << endl; } } o.dec();