debugAssertSpanIndexed method

void debugAssertSpanIndexed(
  1. int fromIndex
)

Debug-only: verifies order/reverse-index agreement over [fromIndex, length): the O(changed-range) inline check that replaces the full consistency sweep on the incremental-mutation hot path. Live nids must index back to their position; zombie entries (freed nids awaiting a batched sweep) are skipped.

Implementation

void debugAssertSpanIndexed(int fromIndex) {
  assert(() {
    for (int i = fromIndex; i < _len; i++) {
      final nid = _orderNids[i];
      if (_nids.keyOf(nid) == null) continue; // zombie: swept later
      assert(
        _indexByNid[nid] == i,
        "VisibleOrderBuffer: order/index disagreement at position $i "
        "(nid $nid indexes to ${_indexByNid[nid]})",
      );
    }
    return true;
  }());
}