ComponentAce.Compression.Libs.ZLib.Deflate.set_data_type C# (CSharp) Method

set_data_type() private method

Set the data type to ASCII or BINARY, using a crude approximation: binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. IN assertion: the fields freq of dyn_ltree are set and the total of all frequencies does not exceed 64K (to fit in an int on 16 bit machines).
private set_data_type ( ) : void
return void
        private void set_data_type()
        {
            int n = 0;
            int ascii_freq = 0;
            int bin_freq = 0;
            while (n < 7)
            {
                bin_freq += dyn_ltree[n * 2]; n++;
            }
            while (n < 128)
            {
                ascii_freq += dyn_ltree[n * 2]; n++;
            }
            while (n < LITERALS)
            {
                bin_freq += dyn_ltree[n * 2]; n++;
            }
            data_type = (bin_freq > (ZLibUtil.URShift(ascii_freq, 2)) ? BlockType.Z_BINARY : BlockType.Z_ASCII);
        }