sizeHint method

  1. @override
int sizeHint(
  1. VariantDeprecationInfo value
)
override

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

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

Implementation

@override
int sizeHint(VariantDeprecationInfo value) {
  switch (value) {
    case VariantDeprecatedWithoutNote():
      return 1;
    case VariantDeprecated(:final _note, :final _since):
      var size = 1;
      size += StrCodec.codec.sizeHint(_note);
      size += 1;
      if (_since != null) {
        size += StrCodec.codec.sizeHint(_since);
      }
      return size;
  }
}