MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / hashStringToInt32

Function hashStringToInt32

web/src/server/free-session/store.ts:576–582  ·  view source on GitHub ↗

Stable 31-bit hash so model-keyed advisory lock ids don't overflow int4.

(s: string)

Source from the content-addressed store, hash-verified

574
575/** Stable 31-bit hash so model-keyed advisory lock ids don't overflow int4. */
576function hashStringToInt32(s: string): number {
577 let h = 0
578 for (let i = 0; i < s.length; i++) {
579 h = (h * 31 + s.charCodeAt(i)) | 0
580 }
581 return Math.abs(h) % 0x40000000
582}

Callers 1

admitFromQueueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected