computeHash static method

String computeHash(
  1. String code
)

Computes content hash for cache invalidation.

Uses a simple hash of the code content. Changes in whitespace or comments will trigger invalidation.

Implementation

static String computeHash(String code) {
  // Simple FNV-1a hash
  var hash = 2166136261;
  for (var i = 0; i < code.length; i++) {
    hash ^= code.codeUnitAt(i);
    hash = (hash * 16777619) & 0xFFFFFFFF;
  }
  return hash.toRadixString(16).padLeft(8, '0');
}