zakarumych / rapid-qoi

Fast implementation of QOI format in Rust
Other
91 stars 1 forks source link

No bounds check on output when decoding #1

Closed CryZe closed 2 years ago

CryZe commented 2 years ago

Whoops, sorry there's actually bounds checks. However none of the unsafety here is even needed.

zakarumych commented 2 years ago

Hi! Thank you for your interest.

I've tweaked the code a lot to ensure no unnecessary bounds checks hinder compiler optimizations. My goal was to outperform reference implementation in C. At the time of the last commit rapid-qoi was faster on encoding, slightly behind on decoding of some patterns and faster on others.

Things that I had to throw out include match statements and most Index trait usage, and most for loops.

CryZe commented 2 years ago

This fully safe version beats the C version in decoding by about 10%: https://gist.github.com/CryZe/282383fdddb1050c1fa6436b7a2c1c59

zakarumych commented 2 years ago

Yea, but how about up to 100% faster decoding?