marshallpierce / rust-base64

base64, in rust
Apache License 2.0
615 stars 115 forks source link

Make DecodeEstimate never panic #216

Closed Nugine closed 1 year ago

Nugine commented 1 year ago

The calculations in GeneralPurposeEstimate::new can be transformed to another formula which never panics. The performance should be the same after optimization.

Do I need to adjust corresponding documentation?

marshallpierce commented 1 year ago

Thanks! Even though surely nobody would ever hit the usize::MAX - 3 limit, it's nice to simply have the panic be impossible. I ended up coming up with a formula that produces slightly tighter assembly: https://github.com/marshallpierce/rust-base64/pull/217