You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
range-set: unify the coalescing step and tidy the algebra
With the algebra now in its own module, clean up a few things the move
made easy to see. None changes behavior: the unit tests added with the
extraction still pass.
- sort_and_merge_range_set() and range_set_union() open-coded the same
final step: append a range, merging it into the previous one when they
overlap or touch, and dropping it when empty. Pull that into
range_set_append_coalesce() and call it from both. union stays a
linear 2-way merge, and sort_and_merge stays an in-place,
allocation-free compaction: range_set_grow() does not reallocate while
the output count stays within the original allocation, and the reset
output cursor never passes the read index, so appending over the same
buffer never clobbers a range not yet read.
- Name the temporaries in range_set_map_across_diff(): "untouched" for
the ranges the diff did not touch and "shifted" for those after they
are shifted to the parent side, so the three-step body reads as its
own description.
- Drop the dead "if (!rs) return" guard in range_set_check_invariants(),
now static with a single, always-valid caller; explain the range_cmp()
comment (start is long, and narrowing the difference to int could flip
the sign); and const-qualify ranges_overlap().
No functional change intended.
Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
0 commit comments