Delphi TStringList to implement on-the-fly compression

I have an application for storing many strings in a TStringList. The strings will be pretty much alike, and it occurs to me that you can compress them on the fly - i.e. Store the specified string as a mixture of unique text fragments plus links to previously saved fragments. String lists, such as fully qualified path lists and file names, must be highly compressed.

Does anyone know of a descendant of TStringlist that implements this, that is, provides read and write access to uncompressed lines, but keeps them internally compressed, so that TStringList.SaveToFile creates a compressed file?

While you can implement this by unpacking the entire list of lines before each access and re-compressing it afterwards, this would be unnecessarily slow. I am for what is effective for incremental operations and random "attempts" and reads.

TIA Ross

+3
source share
4 answers

I don’t think there is a freely available implementation for this (not what I know anyway, although I wrote at least 3 similar constructions in the commercial code), so you have to fold your own.

, , , , , , - , , " " ( -) .

, , , , - "" - , , Marco Cantu . "" (- ) , . , , "", . , , .

"", -, " ", , - , . , , . mod 16 , , -, 40% ( , , ).

+2

Delphi COM API Judy. JudySL .

EDIT: , ( ) . , . , , .

0

, ( ), , :

  • , zlib Delphi, , , 10-100 . / , "", , .

0

I don’t think you really want to compress TStrings elements in memory because it is terribly inefficient. I suggest you look at the TStream implementation in the Zlib block. Just wrap the regular stream in TDecompressionStream on boot and TCompressionStream on save (you can even release the gzip header). Hint: You will want to override LoadFromStream / SaveToStream instead of LoadFromFile / SaveToFile

0
source

Source: https://habr.com/ru/post/1754410/


All Articles