setDataType method

void setDataType()

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).

Implementation

void setDataType() {
  var n = 0;
  var asciiFreq = 0;
  var binFreq = 0;
  while (n < 7) {
    binFreq += _dynamicLengthTree[n * 2];
    n++;
  }
  while (n < 128) {
    asciiFreq += _dynamicLengthTree[n * 2];
    n++;
  }
  while (n < literals) {
    binFreq += _dynamicLengthTree[n * 2];
    n++;
  }
  _dataType = (binFreq > (_rshift(asciiFreq, 2)) ? zBinary : zAscii);
}