configurationSignature property

String get configurationSignature

A deterministic signature suitable for generated definition names.

Implementation

String get configurationSignature {
  final offsetBasis = BigInt.parse('cbf29ce484222325', radix: 16);
  final prime = BigInt.parse('100000001b3', radix: 16);
  final mask = BigInt.parse('ffffffffffffffff', radix: 16);
  var hash = offsetBasis;

  void addByte(int byte) {
    hash ^= BigInt.from(byte);
    hash = (hash * prime) & mask;
  }

  void addInteger(BigInt value) {
    var remaining = value;
    do {
      addByte((remaining & BigInt.from(0xff)).toInt());
      remaining >>= 8;
    } while (remaining != BigInt.zero);
    addByte(0xff);
  }

  addInteger(BigInt.from(rowCount));
  addInteger(BigInt.from(columnCount));
  _rows.forEach(addInteger);
  return hash.toRadixString(16).padLeft(16, '0');
}