contentDisambiguator function
A scroll-stable disambiguator for a colliding text slug, from the tokens
the slug dropped: their slug when short (15 Oct ₹500 paid → 15_500),
else a 6-hex FNV-1a hash of the full normalized text. '' when nothing
was dropped (identical slugs then fall back to a counter).
Implementation
String contentDisambiguator(String text, String normalized) {
final dropped = idDroppedTokens(text);
if (dropped.isEmpty) return '';
final slug = slugify(dropped.join(' '), maxLength: 64);
if (slug != 'node' && slug.length <= _kContentSuffixMaxLen) return slug;
// 32-bit FNV-1a with the prime multiply split so no intermediate exceeds
// 2^53 (identical on the VM and on JavaScript doubles).
var hash = 0x811c9dc5;
for (final code in (normalized.isEmpty ? text : normalized).codeUnits) {
hash = (hash ^ code) & 0xffffffff;
hash = (((hash & 0xff) << 24) + hash * 0x193) & 0xffffffff;
}
return 'h${(hash & 0xffffff).toRadixString(16).padLeft(6, '0')}';
}