dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.21k stars 1.57k forks source link

Please, clarify description of ZLibEncoder.dictionary #30647

Open alsemenov opened 7 years ago

alsemenov commented 7 years ago

The description of property dart:io:ZLibEncoder.dictionary reads:

List<int> dictionary final Initial compression dictionary.

It should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary.

It is not clear how strings (byte sequences) should be packed into List. List<int> is a sequence of integers, so naturally it is only one sequence. How several sequences should be stored in a List<int>? May be the type of dictionary should be List<List<int>>?

lrhn commented 7 years ago

I think the word "strings" is a red herring here. It's just byte sequences. They are (somehow) used to seed the encryption dictionary, and I guess the receiving end must use the same dictionary to seed the decryption (but now I'm guessing).