Skip to content
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

Lzw optimizations #59

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dave-price-parsons
Copy link

Optimized the code in the LZW decompression algorithm. In running of the unit tests, this allowed the decode method to preform about 5.6x faster than the old implementation.

p002308A added 5 commits August 29, 2024 09:38
The codes are maintained in sequential order starting at zero. It is
inefficient to store them in a map with the keys being Integer objects
when they can be stored in an array and indexed directly. This saves on
map lookups each time and removes the creation of excess Integer objects
when primitives work.

In addition, the values being stored as Integer[] was inefficient when
byte[] is what is needed.

These changes make this section of the code run over twice as fast in
testing.
This improves the runtime of the entire lzw decompression by about 67%
in testing.
Removed the heavy math equation done each time, to a simpler one done
rarely. This give a performance boost to the entire LZW decoding method
of about 50%.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant