fastParse method

  1. @override
bool fastParse(
  1. ParseState state
)
override

Parses input data passively, with minimal consumption of system resources during parsing.

Returns true if parsing was successful; otherwise returns false.

if(!fastParse(state)) {
  state.fail(err, state.pos);
}

Implementation

@override
bool fastParse(ParseState state) {
  final pos = state.pos;
  final data = state.data;
  if (pos + _length <= state.length) {
    final c = data.getUint16(pos, Endian.little);
    if (c == _c) {
      var ok = true;
      var newPos = pos + 2;
      for (var i = 1; i < s.length; i++) {
        final c = data.getUint16(newPos, Endian.little);
        if (c != s.codeUnitAt(i)) {
          ok = false;
          break;
        }

        newPos += 2;
      }

      if (ok) {
        state.pos = newPos;
        ws.fastParse(state);
        return true;
      }
    }
  }

  state.fail(_err, pos);
  state.pos = pos;
  return false;
}