Skip to content

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