A minimal fork of the rangeset crate
(0.4.0, from tlsnotary/tlsn-utils)
with a performance fix to the in-place set operations.
RangeSet::union_mut and RangeSet::difference_mut were O(set size) per call
(the stock versions extend+sort_merge the whole vector, or rebuild the set
from an iterator, on every call). Calling them once per item against a growing
set — e.g. mpz's zk-core memory View unioning a range per allocation while
proving a large transcript — is therefore O(N^2).
This fork exploits the maintained sorted/disjoint/non-adjacent invariant:
union_mut: O(1) append/coalesce at the tail; fullsort_mergeonly as a fallback when an incoming range lands out of order.difference_mut: binary-search the overlapping window and splice the trimmed pieces in place (O(log m + affected)), instead of a full rebuild.
All upstream unit tests (36) still pass. The upstream home for this fix is
tlsnotary/tlsn-utils/rangeset; this standalone repo exists so it can be
referenced as a git dependency from the tlsn-mpc-hang proxy-repro reproducer.