Commit da6207f7 authored by Russ Cox's avatar Russ Cox

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
parent 2cd96806
...@@ -108,10 +108,14 @@ func GcImport(imports map[string]*Package, path string) (pkg *Package, err error ...@@ -108,10 +108,14 @@ func GcImport(imports map[string]*Package, path string) (pkg *Package, err error
return Unsafe, nil return Unsafe, nil
} }
srcDir, err := os.Getwd() srcDir := "."
if err != nil { if build.IsLocalImport(path) {
return srcDir, err = os.Getwd()
if err != nil {
return
}
} }
filename, id := FindPkg(path, srcDir) filename, id := FindPkg(path, srcDir)
if filename == "" { if filename == "" {
err = errors.New("can't find import: " + id) err = errors.New("can't find import: " + id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment