copyFrom method

void copyFrom(
  1. Cell other
)

Copies the full cell payload from other into this instance.

This lets hot buffer paths update an existing slot without allocating a replacement Cell object first.

Implementation

void copyFrom(Cell other) {
  if (identical(this, other)) return;
  // Inline the release checks — avoids method call overhead for the common
  // case where there's no pooled content or link to release.
  if (_linkId != 0) {
    _linkFinalizer.detach(_linkFinalizerToken);
    _linkRegistry.release(_linkId);
    _link = const Link();
    _linkId = 0;
  }
  if (_contentKind == _CellContentKind.complex) {
    _pooledContentFinalizer.detach(_pooledContentToken);
    _graphemePool.release(_contentValue);
  }
  _style = other._style;
  _styleId = other._styleId;
  _link = other._link;
  _linkId = other._linkId;
  _width = other._width;
  _contentKind = other._contentKind;
  _contentValue = other._contentValue;
  diffOption = other.diffOption;
  drawable = other.drawable;
  if (_contentKind == _CellContentKind.complex) {
    _graphemePool.retain(_contentValue);
    _attachPooledContentFinalizerIfNeeded();
  }
  if (_linkId != 0) {
    _linkRegistry.retain(_linkId);
    _attachLinkFinalizerIfNeeded();
  }
}