-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go/doc: if New weren't destructively, cmd/api would be faster #4380
Labels
Comments
Here's what needs to be done to goapi to make it faster, once this is fixed: diff -r 821585f8baba src/cmd/api/goapi.go --- a/src/cmd/api/goapi.go Fri Nov 16 11:53:26 2012 -0800 +++ b/src/cmd/api/goapi.go Fri Nov 16 13:15:51 2012 -0800 @@ -353,6 +353,15 @@ return } +var parsedFileCache = make(map[string]*ast.File) + +func parseFile(filename string) (*ast.File, error) { + if f, ok := parsedFileCache[filename]; ok { + return f, nil + } + return parser.ParseFile(fset, filename, nil, 0) +} + // WalkPackage walks all files in package `name'. // WalkPackage does nothing if the package has already been loaded. func (w *Walker) WalkPackage(name string) { @@ -386,7 +395,8 @@ files := append(append([]string{}, info.GoFiles...), info.CgoFiles...) for _, file := range files { - f, err := parser.ParseFile(fset, filepath.Join(dir, file), nil, 0) + filename := filepath.Join(dir, file) + f, err := parseFile(filename) if err != nil { log.Fatalf("error parsing package %s, file %s: %v", name, file, err) } @@ -395,6 +405,8 @@ for _, dep := range fileDeps(f) { w.WalkPackage(dep) } + parsedFileCache[filename] = f + } if *verbose { |
This issue was updated by revision aeca7a7. R=golang-dev, remyoudompheng, minux.ma, gri CC=golang-dev http://golang.org/cl/6845058 |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: