MCPcopy Create free account
hub / github.com/modem-dev/hunk / lineSetFingerprint

Function lineSetFingerprint

src/ui/diff/useHighlightedDiff.ts:30–47  ·  view source on GitHub ↗

Summarize rendered diff lines without serializing whole arrays into the cache key.

(lines: string[] | undefined)

Source from the content-addressed store, hash-verified

28
29/** Summarize rendered diff lines without serializing whole arrays into the cache key. */
30function lineSetFingerprint(lines: string[] | undefined) {
31 let totalChars = 0;
32 let hash = 2166136261;
33
34 for (const line of lines ?? []) {
35 totalChars += line.length;
36
37 for (let index = 0; index < line.length; index += 1) {
38 hash ^= line.charCodeAt(index);
39 hash = Math.imul(hash, 16777619);
40 }
41
42 hash ^= 10;
43 hash = Math.imul(hash, 16777619);
44 }
45
46 return `${lines?.length ?? 0}:${totalChars}:${(hash >>> 0).toString(36)}`;
47}
48
49/** Build a fallback fingerprint from parsed metadata when raw patch text is unavailable. */
50function metadataFingerprint(file: DiffFile) {

Callers 1

metadataFingerprintFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected