Skip to content

Commit

Permalink
Auto merge of #110634 - saethlin:pointy-decoder, r=cjgillot
Browse files Browse the repository at this point in the history
Rewrite MemDecoder around pointers not a slice

This is basically rust-lang/rust#109910 but I'm being a lot more aggressive. The pointer-based structure means that it makes a lot more sense to absorb more complexity into `MemDecoder`, most of the diff is just complexity moving from one place to another.

The primary argument for this structure is that we only incur a single bounds check when doing multi-byte reads from a `MemDecoder`. With the slice-based implementation we need to do those with `data[position..position + len]` , which needs to account for `position + len` wrapping. It would be possible to dodge the first bounds check if we stored a slice that starts at `position`, but that would require updating the pointer and length on every read.

This PR also embeds the failure path in a separate function, which means that this PR should subsume all the perf wins observed in rust-lang/rust#109867.
  • Loading branch information
bors committed Apr 26, 2023
2 parents ad02c71 + 10dd8e7 commit 9467bb5
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 9467bb5

Please sign in to comment.