]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: avoid os.Getwd if not necessary
authorRuss Cox <rsc@golang.org>
Thu, 14 Feb 2013 19:46:03 +0000 (14:46 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 14 Feb 2013 19:46:03 +0000 (14:46 -0500)
Getwd can be very expensive.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7312100

src/pkg/go/types/gcimporter.go

index 7e93dc9779e5132a41872c4539ac97f0d1cb99f2..0991bade146267d0630ece1b4fff09738bd0faca 100644 (file)
@@ -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)