Skip to content

Commit 3d8c0a4

Browse files
committed
Stop iterating over all resources for finding matching identifiers
1 parent 764750f commit 3d8c0a4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/foam-vscode/src/core/model/workspace.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,19 @@ export class FoamWorkspace implements IDisposable {
104104
public getIdentifier(forResource: URI, exclude?: URI[]): string {
105105
const amongst = [];
106106
const basename = forResource.getBasename();
107-
for (const res of this._resources.values()) {
108-
// skip elements that cannot possibly match
109-
if (!res.uri.path.endsWith(basename)) {
110-
continue;
111-
}
107+
108+
this.listByIdentifier(basename).map(res => {
112109
// skip self
113110
if (res.uri.isEqual(forResource)) {
114-
continue;
111+
return;
115112
}
113+
116114
// skip exclude list
117115
if (exclude && exclude.find(ex => ex.isEqual(res.uri))) {
118-
continue;
116+
return;
119117
}
120118
amongst.push(res.uri);
121-
}
119+
});
122120

123121
let identifier = FoamWorkspace.getShortestIdentifier(
124122
forResource.path,

0 commit comments

Comments
 (0)