Subject: Re: [quicwg/base-drafts] VarInt decoding pseudocode (#4316)

From: Martin Thomson <[email-masked]>
Date: Tue, 03 Nov 2020 15:33:26 -0800

Merged #4316 into master.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/4316#event-3955202430

---

From: Jana Iyengar <[email-masked]>
Date: Tue, 03 Nov 2020 15:33:28 -0800

@janaiyengar commented on this pull request.

> +read from a stream of bytes.  The function ReadVarint takes a single argument, a
+sequence of bytes which can be read in network byte order.
+
+~~~
+ReadVarint(data):
+  // The length of variable-length integers is encoded in the
+  // first two bits of the first byte.
+  v = data.next_byte()
+  length = (1 << (v >> 6))
+
+  // Once the length is known, remove these bits and read any
+  // remaining bytes.
+  v = v & 0x3f
+  repeat length-1 times:
+    v = (v << 8) + data.next_byte()
+  return v

Yeah -- there's nothing here that is endian-specific.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/4316#discussion_r517016465