Skip to content

Commit 78b0c66

Browse files
author
Benjamin Pasero
committed
files - lazy trie
1 parent b2450ce commit 78b0c66

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/vs/platform/files/common/fileService.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,25 @@ export class FileService extends Disposable implements IFileService {
164164
private async doResolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat> {
165165
const provider = await this.withProvider(resource);
166166

167-
// leverage a trie to check for recursive resolving
168167
const resolveTo = options && options.resolveTo;
169-
const trie = TernarySearchTree.forPaths<true>();
170-
trie.set(resource.toString(), true);
171-
if (isNonEmptyArray(resolveTo)) {
172-
resolveTo.forEach(uri => trie.set(uri.toString(), true));
173-
}
174-
175168
const resolveSingleChildDescendants = !!(options && options.resolveSingleChildDescendants);
176169
const resolveMetadata = !!(options && options.resolveMetadata);
177170

178171
const stat = await provider.stat(resource);
179172

173+
let trie: TernarySearchTree<boolean> | undefined;
174+
180175
return this.toFileStat(provider, resource, stat, undefined, resolveMetadata, (stat, siblings) => {
181176

177+
// lazy trie to check for recursive resolving
178+
if (!trie) {
179+
trie = TernarySearchTree.forPaths<true>();
180+
trie.set(resource.toString(), true);
181+
if (isNonEmptyArray(resolveTo)) {
182+
resolveTo.forEach(uri => trie!.set(uri.toString(), true));
183+
}
184+
}
185+
182186
// check for recursive resolving
183187
if (Boolean(trie.findSuperstr(stat.resource.toString()) || trie.get(stat.resource.toString()))) {
184188
return true;

0 commit comments

Comments
 (0)