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

Method buildAsync

src/native-ts/file-index/index.ts:95–133  ·  view source on GitHub ↗
(
    fileList: string[],
    markQueryable: () => void,
  )

Source from the content-addressed store, hash-verified

93 }
94
95 private async buildAsync(
96 fileList: string[],
97 markQueryable: () => void,
98 ): Promise<void> {
99 const seen = new Set<string>()
100 const paths: string[] = []
101 let chunkStart = performance.now()
102 for (let i = 0; i < fileList.length; i++) {
103 const line = fileList[i]!
104 if (line.length > 0 && !seen.has(line)) {
105 seen.add(line)
106 paths.push(line)
107 }
108 // Check every 256 iterations to amortize performance.now() overhead
109 if ((i & 0xff) === 0xff && performance.now() - chunkStart > CHUNK_MS) {
110 await yieldToEventLoop()
111 chunkStart = performance.now()
112 }
113 }
114
115 this.resetArrays(paths)
116
117 chunkStart = performance.now()
118 let firstChunk = true
119 for (let i = 0; i < paths.length; i++) {
120 this.indexPath(i)
121 if ((i & 0xff) === 0xff && performance.now() - chunkStart > CHUNK_MS) {
122 this.readyCount = i + 1
123 if (firstChunk) {
124 markQueryable()
125 firstChunk = false
126 }
127 await yieldToEventLoop()
128 chunkStart = performance.now()
129 }
130 }
131 this.readyCount = paths.length
132 markQueryable()
133 }
134
135 private buildIndex(paths: string[]): void {
136 this.resetArrays(paths)

Callers 1

loadFromFileListAsyncMethod · 0.95

Calls 6

resetArraysMethod · 0.95
indexPathMethod · 0.95
yieldToEventLoopFunction · 0.85
hasMethod · 0.45
addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected