Skip to content

Commit c4c4df5

Browse files
committed
refactor: use doc.version instead of text hash for parse cache key
1 parent 0ddc451 commit c4c4df5

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

src/utils/parse.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import type { ValidNode } from '#types/extractor'
22
import type { TextDocument } from 'vscode'
3-
import { createHash } from 'node:crypto'
43
import { memoize } from './memoize'
54

6-
function computeHash(text: string) {
7-
return createHash('sha1').update(text).digest('hex')
8-
}
9-
105
export function createCachedParse<T extends ValidNode>(
116
parse: (text: string) => T | null,
127
) {
138
return memoize(
149
(doc: TextDocument) => parse(doc.getText()),
15-
{ getKey: (doc) => `${doc.uri}:${computeHash(doc.getText())}` },
10+
{ getKey: (doc) => `${doc.uri}:${doc.version}` },
1611
)
1712
}

0 commit comments

Comments
 (0)