mirror of
https://github.com/golang/go
synced 2024-11-18 19:54:44 -07:00
go.tools/importer: fix classic closing-over-induction-variable gotcha.
Now we actually prefetch all n packages, instead of prefetching the last one n times. This yields a further 22% improvement, which is more like what I was hoping for. It makes me so sad that Go reproduced one of the best-known mistakes of JavaScript. D'oh! R=crawshaw CC=golang-dev https://golang.org/cl/13379046
This commit is contained in:
parent
e2921e188a
commit
f5ac829804
@ -177,7 +177,7 @@ func (imp *Importer) LoadPackage(importPath string) (*PackageInfo, error) {
|
|||||||
if files, err := loadPackage(imp.config.Build, imp.Fset, importPath); err == nil {
|
if files, err := loadPackage(imp.config.Build, imp.Fset, importPath); err == nil {
|
||||||
// Kick off asynchronous I/O and parsing for the imports.
|
// Kick off asynchronous I/O and parsing for the imports.
|
||||||
for path := range imports(importPath, files) {
|
for path := range imports(importPath, files) {
|
||||||
go func() { imp.LoadPackage(path) }()
|
go func(path string) { imp.LoadPackage(path) }(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type-check the package.
|
// Type-check the package.
|
||||||
|
Loading…
Reference in New Issue
Block a user