Skip to content

Commit e0c0e9c

Browse files
authored
Skip more work when creating LSP watch globs (#1015)
1 parent 7a17117 commit e0c0e9c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

internal/project/watch.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99
"time"
1010

11+
"github.com/microsoft/typescript-go/internal/core"
1112
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
1213
"github.com/microsoft/typescript-go/internal/tspath"
1314
)
@@ -101,8 +102,16 @@ func createResolutionLookupGlobMapper(host ProjectHost) func(data map[tspath.Pat
101102

102103
// dir -> recursive
103104
globSet := make(map[string]bool)
105+
var seenDirs core.Set[string]
104106

105107
for path, fileName := range data {
108+
// Assuming all of the input paths are filenames, we can avoid
109+
// duplicate work by only taking one file per dir, since their outputs
110+
// will always be the same.
111+
if !seenDirs.AddIfAbsent(tspath.GetDirectoryPath(string(path))) {
112+
continue
113+
}
114+
106115
w := getDirectoryToWatchFailedLookupLocation(
107116
fileName,
108117
path,

0 commit comments

Comments
 (0)