r-neal-kelly / the_scriptures

A Scriptural Study Suite
https://r-neal-kelly.github.io/the_scriptures/
Other
0 stars 0 forks source link

Improve LZSS Compressor by using TypedArrays #13

Open r-neal-kelly opened 9 months ago

r-neal-kelly commented 9 months ago

Just like in the decompressor, the compressor could use typed arrays instead to speed up performance. Essentially we can use a bigger typed array than needed and just read a splice from it for the text decoder at the end of the function.

We would just guess about the size, and do maybe 1.2 times the size of the original text.

Although it is LZSS compression, we allow certain symbols in the text that otherwise are used for the compressor, and we have to escape those, and so the text is actually capable of being bigger than the source still! Annoyingly enough.

We could also dynamically grow the typed array, which leads me to believe we could take advantage of our own dynamic array type.