trimScratchArrays method

void trimScratchArrays()

Reallocates scratch arrays to fit _lastPrecomputedCount (or empty if zero). Call when the tree shrinks significantly and memory matters.

Implementation

void trimScratchArrays() {
  final n = _lastPrecomputedCount;
  if (n == 0) {
    _depthScratch = Int32List(0);
    _stablePrefix = Float64List(0);
    _subtreeEndIndex = Int32List(0);
    _subtreeBottomByIndex = Float64List(0);
  } else {
    _depthScratch = Int32List(n);
    _stablePrefix = Float64List(n + 1);
    _subtreeEndIndex = Int32List(n);
    _subtreeBottomByIndex = Float64List(n);
  }
}