This change makes encoding about 7x faster than the current implementation, on my machine.
Before:
hex_encode time: [77.149 us 77.581 us 78.015 us]
After:
hex_encode time: [10.214 us 10.270 us 10.336 us]
Benchmarks per commit
Current main branch (aa8f3001fed80718ea8e33ab5e278351d3ef5036)
```
hex_encode time: [77.149 us 77.581 us 78.015 us]
```
First commit of this PR: Adjust #[inline] on encoding functions (97abf032d3430af4b2f6fa9b85806d99b2585b9d)
```
hex_encode time: [37.251 us 37.412 us 37.583 us]
change: [-52.047% -51.748% -51.412%] (p = 0.00 < 0.05)
Performance has improved.
```
Second commit of this PR: Use encode_to_slice in encode (0129182ab8c57f9962c52367dc9665d69a3acab2)
```
hex_encode time: [27.029 us 27.230 us 27.476 us]
change: [-27.711% -27.244% -26.782%] (p = 0.00 < 0.05)
Performance has improved.
```
Third commit of this PR: Use chunks_exact_mut instead of generate_iter (19b333d91cbbc58274cdcd948ef0b2f6078b5a2b)
```
hex_encode time: [10.214 us 10.270 us 10.336 us]
change: [-62.198% -61.839% -61.444%] (p = 0.00 < 0.05)
Performance has improved.
```
This also adds encode_to_slice_upper, which is needed to improve the performance of encode_upper. (fixes #45).
This change makes encoding about 7x faster than the current implementation, on my machine.
Before:
After:
Benchmarks per commit
Current main branch (aa8f3001fed80718ea8e33ab5e278351d3ef5036) ``` hex_encode time: [77.149 us 77.581 us 78.015 us] ``` First commit of this PR: Adjust #[inline] on encoding functions (97abf032d3430af4b2f6fa9b85806d99b2585b9d) ``` hex_encode time: [37.251 us 37.412 us 37.583 us] change: [-52.047% -51.748% -51.412%] (p = 0.00 < 0.05) Performance has improved. ``` Second commit of this PR: Use encode_to_slice in encode (0129182ab8c57f9962c52367dc9665d69a3acab2) ``` hex_encode time: [27.029 us 27.230 us 27.476 us] change: [-27.711% -27.244% -26.782%] (p = 0.00 < 0.05) Performance has improved. ``` Third commit of this PR: Use chunks_exact_mut instead of generate_iter (19b333d91cbbc58274cdcd948ef0b2f6078b5a2b) ``` hex_encode time: [10.214 us 10.270 us 10.336 us] change: [-62.198% -61.839% -61.444%] (p = 0.00 < 0.05) Performance has improved. ```This also adds encode_to_slice_upper, which is needed to improve the performance of encode_upper. (fixes #45).