From: Russ Cox Date: Thu, 14 Feb 2013 19:46:03 +0000 (-0500) Subject: go/types: avoid os.Getwd if not necessary X-Git-Tag: go1.1rc2~1030 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=da6207f7a48a0e0bb961e0d80ca454ebd02180da;p=gostls13.git go/types: avoid os.Getwd if not necessary Getwd can be very expensive. R=golang-dev, r CC=golang-dev https://golang.org/cl/7312100 --- diff --git a/src/pkg/go/types/gcimporter.go b/src/pkg/go/types/gcimporter.go index 7e93dc9779..0991bade14 100644 --- a/src/pkg/go/types/gcimporter.go +++ b/src/pkg/go/types/gcimporter.go @@ -108,10 +108,14 @@ func GcImport(imports map[string]*Package, path string) (pkg *Package, err error return Unsafe, nil } - srcDir, err := os.Getwd() - if err != nil { - return + srcDir := "." + if build.IsLocalImport(path) { + srcDir, err = os.Getwd() + if err != nil { + return + } } + filename, id := FindPkg(path, srcDir) if filename == "" { err = errors.New("can't find import: " + id)