clear method

void clear(
  1. ByteData data,
  2. bool isFresh
)

Clear the allocated data contents.

Param isFresh is true if the given data has been freshly allocated, depending on the allocator implementation, clearing may be unnecessary.

Implementation

void clear(ByteData data, bool isFresh) {
  final length = data.lengthInBytes;
  final length64b = (length / 8).floor();
  // fillRange iterates over data so it's faster with larger data type
  if (length64b > 0) data.buffer.asUint64List().fillRange(0, length64b, 0);
  data.buffer.asUint8List().fillRange(length64b * 8, length % 8, 0);
}