MCPcopy Index your code
hub / github.com/codeaashu/claude-code / intern

Method intern

src/ink/screen.ts:29–48  ·  view source on GitHub ↗
(char: string)

Source from the content-addressed store, hash-verified

27 private ascii: Int32Array = initCharAscii() // charCode → index, -1 = not interned
28
29 intern(char: string): number {
30 // ASCII fast-path: direct array lookup instead of Map.get
31 if (char.length === 1) {
32 const code = char.charCodeAt(0)
33 if (code < 128) {
34 const cached = this.ascii[code]!
35 if (cached !== -1) return cached
36 const index = this.strings.length
37 this.strings.push(char)
38 this.ascii[code] = index
39 return index
40 }
41 }
42 const existing = this.stringMap.get(char)
43 if (existing !== undefined) return existing
44 const index = this.strings.length
45 this.strings.push(char)
46 this.stringMap.set(char, index)
47 return index
48 }
49
50 get(index: number): string {
51 return this.strings[index] ?? ' '

Callers 4

flushBufferFunction · 0.45
internHyperlinkFunction · 0.45
migrateScreenPoolsFunction · 0.45
internCharStringFunction · 0.45

Calls 3

getMethod · 0.65
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected