use ternary search tree for uris instead of paths, fyi @bpasero, @sandy081, @roblourens, https://github.com/microsoft/vscode/issues/93368

This commit is contained in:
Johannes Rieken
2020-04-08 10:06:57 +02:00
parent 2127c70cca
commit 960205b8a0
6 changed files with 30 additions and 24 deletions

View File

@@ -116,7 +116,7 @@ class ExtHostWorkspaceImpl extends Workspace {
}
private readonly _workspaceFolders: vscode.WorkspaceFolder[] = [];
private readonly _structure = TernarySearchTree.forPaths<vscode.WorkspaceFolder>();
private readonly _structure = TernarySearchTree.forUris<vscode.WorkspaceFolder>();
constructor(id: string, private _name: string, folders: vscode.WorkspaceFolder[], configuration: URI | null, private _isUntitled: boolean) {
super(id, folders.map(f => new WorkspaceFolder(f)), configuration);
@@ -124,7 +124,7 @@ class ExtHostWorkspaceImpl extends Workspace {
// setup the workspace folder data structure
folders.forEach(folder => {
this._workspaceFolders.push(folder);
this._structure.set(folder.uri.toString(), folder);
this._structure.set(folder.uri, folder);
});
}
@@ -141,15 +141,15 @@ class ExtHostWorkspaceImpl extends Workspace {
}
getWorkspaceFolder(uri: URI, resolveParent?: boolean): vscode.WorkspaceFolder | undefined {
if (resolveParent && this._structure.get(uri.toString())) {
if (resolveParent && this._structure.get(uri)) {
// `uri` is a workspace folder so we check for its parent
uri = dirname(uri);
}
return this._structure.findSubstr(uri.toString());
return this._structure.findSubstr(uri);
}
resolveWorkspaceFolder(uri: URI): vscode.WorkspaceFolder | undefined {
return this._structure.get(uri.toString());
return this._structure.get(uri);
}
}