fastParse method

String fastParse(
  1. List<int> bytes,
  2. int fieldOffset,
  3. int fieldLen
)

Performs a faster byte[] to String conversion under the assumption the content is represented with one byte per char

Implementation

String fastParse(
    final List<int> bytes, final int fieldOffset, final int fieldLen) {
  // faster reading path, the decoder is for some reason slower,
  // probably because it has to make extra checks to support multibyte chars
  final chars = List.filled(fieldLen, 0); //  List<int>(fieldLen);
  for (var i = 0; i < fieldLen; i++) {
    // force the byte to a positive integer interpretation before casting to char
    chars[i] = (0x00FF & bytes[fieldOffset + i]);
  }
  return String.fromCharCodes(chars);
}