runWithSubtreeSizeUpdatesSuppressed method

void runWithSubtreeSizeUpdatesSuppressed(
  1. void body()
)

ADVANCED. Suppresses the inlined subtree-size cache callbacks for the closure body. Caller is fully responsible for keeping the subtree-size cache consistent across the body — typically by pre-bumping via bumpFromSelf before the closure runs. Misuse silently corrupts the cache.

Used by _purgeAndRemoveFromOrder Step 3 to avoid double-decrementing the cache on top of Step 1's pre-bump. Most callers should use rebuild instead.

Re-entrant safe — nested calls preserve the prior suppression state.

Implementation

void runWithSubtreeSizeUpdatesSuppressed(void Function() body) {
  final wasSuppressed = _suppress;
  _suppress = true;
  try {
    body();
  } finally {
    _suppress = wasSuppressed;
  }
}