startsWithAscii method

bool startsWithAscii(
  1. String prefix
)

Whether this view starts with the UTF-8 encoding of prefix.

Only valid for ASCII prefixes; non-ASCII comparisons go through equalsString or a StringView of encoded bytes.

Implementation

bool startsWithAscii(String prefix) {
  if (prefix.length > byteLength) return false;
  for (var i = 0; i < prefix.length; i++) {
    final unit = prefix.codeUnitAt(i);
    if (unit > 0x7F || bytes[start + i] != unit) return false;
  }
  return true;
}