Closed dralley closed 2 years ago
Do you have a real world benchmark where this actually matters? I am deeply skeptical that it matters at all. The stack size increase is, if I'm not mistaken, 24 bytes. If that's really an issue, then you might consider boxing the decoder. The branches seem totally negligible because they only happen once per read
call, and presumably you're passing a big buffer. So the branches are going to be pretty thoroughly amortized.
This sounds like additional complexity for no real gain as far as I'm concerned. Dropping the feature and also introducing a runtime panic based on the size of the buffer also sounds pretty gross too. In order for me to be okay with that, I'd need a super compelling reason.
A provided buffer that's smaller than 7 bytes is probably an extremely rare case. It would be nice if I could skip paying for the larger decoder struct and the branches in that case and just panic (or maybe statically assert?) if I do something silly.