Skip to content

Commit 04b8a75

Browse files
authoredAug 13, 2024··
lsp/perf: don't traverse .git or .idea dirs (#984)
In the Regal workspace, the time to find the workspace .rego files went from 70 ms to 7 ms. Nice! Signed-off-by: Anders Eknert <anders@styra.com>
1 parent 4ebdd7e commit 04b8a75

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎internal/lsp/server.go

+6
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,12 @@ func (l *LanguageServer) loadWorkspaceContents(ctx context.Context, newOnly bool
18061806
return fmt.Errorf("failed to walk workspace dir %q: %w", path, err)
18071807
}
18081808

1809+
// These directories often have thousands of items we don't care about,
1810+
// so don't even traverse them.
1811+
if d.IsDir() && (d.Name() == ".git" || d.Name() == ".idea") {
1812+
return filepath.SkipDir
1813+
}
1814+
18091815
// TODO(charlieegan3): make this configurable for things like .rq etc?
18101816
if d.IsDir() || !strings.HasSuffix(path, ".rego") {
18111817
return nil

0 commit comments

Comments
 (0)
Please sign in to comment.