Compression of ASCII strings in C

前端 未结 6 1585
梦如初夏
梦如初夏 2021-01-02 03:55

I have some C code that stores ASCII strings in memory as a four byte length followed by the string. The string lengths are in the range 10-250 bytes.

To reduce occ

6条回答
  •  盖世英雄少女心
    2021-01-02 04:42

    Zlib is definitely your friend here, but be sure to perform a few tests to detect the average string length at which compression starts to be beneficial, because of the small overhead of compression headers.

    For example, you might discover that under 20 characters, the compressed string is actually bigger, and therefore only compress the longer strings.

提交回复
热议问题