sizeHint method

  1. @override
int sizeHint(
  1. Map<K, V> value

If possible give a hint of expected size of the encoding.

This method is used inside default implementation of encode to avoid re-allocations.


int sizeHint(Map<K, V> value) {
  var size = CompactCodec.codec.sizeHint(value.length);
  for (final entry in value.entries) {
    size += keyCodec.sizeHint(entry.key);
    size += valueCodec.sizeHint(entry.value);
  return size;