Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This series of 5 commits refactors how the code parses
u32
values. The cumulative impact on the runtime of thedecode/generated-png:noncompressed-8x8.png
benchmark looks as follows:I expect that this PR will have minimal impact on bigger images, so I didn't even try running the other benchmarks (I assume that any changes observed in the other benchmarks would be just statistical noise).
I think that this PR turned out quite nicely from code simplification and readability perspective. Even if there was no performance impact, I think it might be desirable to land it from this perspective.
Various notes:
u32
values.decoder::tests::no_data_dup_on_finish
- only one test... :-(BufRead
changes land, maybe we should tweak therender_images
test to work withBufReader::with_capacity(1, <original input>)
which should test dripping the input byte-by-byte.BufReader::with_capacity
calls insrc/decoder/mod.rs
so that a buffer of only 1 byte was used.U32ValueKind::Type
after anIDAT
chunk really needs to go through 2 state transitions (with a detour viaDecoded::ImageDataFlushed
during whichself.state
is set to the old/unchanged value). This is probably in the unnecessary-microoptimizations territory, but I was hoping to simplify the code a bit more. Still... I don't see how to do this cleanly.