Skip to content

Commit

Permalink
Stop iterating over all resources for finding matching identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
pderaaij committed Nov 12, 2024
1 parent 764750f commit 3d8c0a4
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/foam-vscode/src/core/model/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,19 @@ export class FoamWorkspace implements IDisposable {
public getIdentifier(forResource: URI, exclude?: URI[]): string {
const amongst = [];
const basename = forResource.getBasename();
for (const res of this._resources.values()) {
// skip elements that cannot possibly match
if (!res.uri.path.endsWith(basename)) {
continue;
}

this.listByIdentifier(basename).map(res => {
// skip self
if (res.uri.isEqual(forResource)) {
continue;
return;
}

// skip exclude list
if (exclude && exclude.find(ex => ex.isEqual(res.uri))) {
continue;
return;
}
amongst.push(res.uri);
}
});

let identifier = FoamWorkspace.getShortestIdentifier(
forResource.path,
Expand Down

0 comments on commit 3d8c0a4

Please sign in to comment.