-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Faster decode #255
Faster decode #255
Conversation
While it might make stuff faster I feel like we've lost some of the defensive programming and simplicity of the original design. It was nice having the symmetric way to
The pointer changes might work if perfectly done, but the moment there's a misalignment anywhere you have pretty big problems debugging and random bytes might be interpreted as OPs, whereas before you always had the for loop |
This was a fairly minor speed gain so I won't mind reverting it. On the other hand, I'm not sure favouring a minor visual symmetry over performance is a good goal 😆
Yeah, but the encoder already does it this way. The main downside here is having to deal with the (purely theoretical) edge case with a starting run. Ideally, the spec could just be clarified to rule out the edge case. It wouldn't really be a breaking change as the current encoder doesn't trigger it and there probably aren't any other encoders that do. I did browse over a number of other implementations and spotted a few decoders that already don't handle the edge case, so ruling it out in the spec would really just be affirming that those existing decoders are actually compliant. |
As mentioned in #256 I want to maintain the readability of this implementation. If you (and/or @ProkopRandacek) want to fork this repo and maintain a faster version of this library, I'm more than happy to link it in the Readme.
That's... troubling. I'm hesitant to change the spec now, as it spells out the current behavior (every pixel is put into the index). I think it's more reasonable to fix these non-compliant decoders. |
Sure, I understand.
The problem is that the edge case is very easy to overlook and it's very easy/tempting to write a decoder that doesn't deal with it, especially as it won't fail any tests nor on any images the encoder would ever produce. If you're sure you want this to be spec and make sure people write compliant decoders, I think you'll need to:
Regardless of whether you want to keep the edge case or rule it out though, I do think the spec needs to be explicit about it either way. |
This makes two changes to improve decode performance:
Together these changes showed a 20% improvement to decode speed on a set of test images I used. If the changes are all good, I could follow up with a similar change for encode.