FanTranslatorsInternational / Kuriimu2

Kuriimu is a general purpose game translation project manager and toolkit for authors of fan translations and game mods.
GNU General Public License v3.0
311 stars 56 forks source link

Compression streams #166

Open onepiecefreak3 opened 3 years ago

onepiecefreak3 commented 3 years ago

What? A possibility to wrap compressions into a stream, instead of always decompressing the whole file.

Why? This gains memory efficiency if only a small information is needed from the file (even more efficiency if said information is at the beginning of the file) Easier usage throughout the plugins, since it wouldn't require creating a buffer stream and position management.

How? Compressions would need to be redesigned in a more granular structure to support "on-demand compression of blocks". This isn't thought and would be an even heavier increase in efficiency, but this can be added later in the background. Base requirement is a Stream class, that can take a baseStream, KompressionConfiguration, and compressionMode (Compress/Decompress).

Additional benefits? The usage of Compressions.cs could be condensed, since a read-/writeable stream would already be returned. It wouldn't require building the configuration and then calling the De-/Compress methods with a buffer stream (benefit as explained above). It's possible to condense the usage of the library to Compressions.[Compression].Wrap(baseStream, mode), or by having separwte wrap methods for de-/compressing. This requires adding the Wrap methods to the configuration. This method would build and wrap the configuration accordingly.