decode static method
- List<
int> bytes, - MessageVisitor visitor
One-shot decode of a whole, already-in-memory bytes buffer into
visitor (CORELIB_PLAN §6.1 convenience). This is the common case
(deserialize, any message that fits in memory), so it runs the fast
contiguous path — advancing an index over the buffer rather than the
per-byte streaming state machine — for a large decode speed-up. It
produces byte-identical visitor calls and the same DecodeStatus as
feeding the same bytes through feed; use a streaming Decoder + feed
when the input arrives in chunks.
A List<int> that is not a Uint8List takes the streaming engine
instead: the contiguous walker needs the concrete type for its bulk moves,
and copying the input to get it would be a copy the wire sizes, which
§6.6 forbids the codec. Same visitor calls, same outcome — one engine is
simply faster on the type it can index directly.
Implementation
static DecodeStatus decode(List<int> bytes, MessageVisitor visitor) {
if (bytes is Uint8List) {
return _ContiguousDecoder(bytes).run(visitor);
}
return Decoder(visitor).feed(bytes);
}