Skip to content

Commit 61f6911

Browse files
committed
extract caching code
1 parent 7308e7a commit 61f6911

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/dictionary/parallel_parser.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class ParserWorker {
3030
switch (result.type) {
3131
case "value":
3232
resolve(result.value);
33-
this.#cachedSource = source;
34-
this.#cachedDictionary = result.value;
3533
break;
3634
case "error":
3735
reject(
@@ -66,7 +64,10 @@ class ParserWorker {
6664
if (this.#cachedSource === source) {
6765
return this.#cachedDictionary;
6866
} else {
69-
return await this.#rawParse(position, source);
67+
const dictionary = await this.#rawParse(position, source);
68+
this.#cachedSource = source;
69+
this.#cachedDictionary = dictionary;
70+
return dictionary;
7071
}
7172
}
7273
}

0 commit comments

Comments
 (0)