mirror of https://github.com/golang/go.git
internal/lsp/cache: preallocate internal maps when cloning snapshots
For large codebases, the cost of copying these maps can be fairly high, especially when it needs to repeatedly grow the map's underlying storage. Preallocate these to the size of the original snapshot maps to prevent the need to grow the storage during the clone. Updates golang/go#45686 Change-Id: I4cfcd5b7cba8110e4f7e706fd9ea968aaeb6ff0c Reviewed-on: https://go-review.googlesource.com/c/tools/+/312689 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
e435455aa1
commit
f74a6698e3
|
|
@ -1342,18 +1342,18 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
|
|||
builtin: s.builtin,
|
||||
initializeOnce: s.initializeOnce,
|
||||
initializedErr: s.initializedErr,
|
||||
ids: make(map[span.URI][]packageID),
|
||||
importedBy: make(map[packageID][]packageID),
|
||||
metadata: make(map[packageID]*metadata),
|
||||
packages: make(map[packageKey]*packageHandle),
|
||||
actions: make(map[actionKey]*actionHandle),
|
||||
files: make(map[span.URI]source.VersionedFileHandle),
|
||||
goFiles: make(map[parseKey]*parseGoHandle),
|
||||
workspacePackages: make(map[packageID]packagePath),
|
||||
unloadableFiles: make(map[span.URI]struct{}),
|
||||
parseModHandles: make(map[span.URI]*parseModHandle),
|
||||
modTidyHandles: make(map[span.URI]*modTidyHandle),
|
||||
modWhyHandles: make(map[span.URI]*modWhyHandle),
|
||||
ids: make(map[span.URI][]packageID, len(s.ids)),
|
||||
importedBy: make(map[packageID][]packageID, len(s.importedBy)),
|
||||
metadata: make(map[packageID]*metadata, len(s.metadata)),
|
||||
packages: make(map[packageKey]*packageHandle, len(s.packages)),
|
||||
actions: make(map[actionKey]*actionHandle, len(s.actions)),
|
||||
files: make(map[span.URI]source.VersionedFileHandle, len(s.files)),
|
||||
goFiles: make(map[parseKey]*parseGoHandle, len(s.goFiles)),
|
||||
workspacePackages: make(map[packageID]packagePath, len(s.workspacePackages)),
|
||||
unloadableFiles: make(map[span.URI]struct{}, len(s.unloadableFiles)),
|
||||
parseModHandles: make(map[span.URI]*parseModHandle, len(s.parseModHandles)),
|
||||
modTidyHandles: make(map[span.URI]*modTidyHandle, len(s.modTidyHandles)),
|
||||
modWhyHandles: make(map[span.URI]*modWhyHandle, len(s.modWhyHandles)),
|
||||
workspace: newWorkspace,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue