Summarize rendered diff lines without serializing whole arrays into the cache key.
(lines: string[] | undefined)
| 28 | |
| 29 | /** Summarize rendered diff lines without serializing whole arrays into the cache key. */ |
| 30 | function 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. */ |
| 50 | function metadataFingerprint(file: DiffFile) { |
no outgoing calls
no test coverage detected