mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: use bufio.Reader directly in lexer
Removes an intermediate layer of functions that was clogging up a corner of the compiler's profile graph. I can't measure a performance improvement running a large build like jujud, but the profile reports less total time spent in gc.(*lexer).getr. Change-Id: I3000585cfcb0f9729d3a3859e9023690a6528591 Reviewed-on: https://go-review.googlesource.com/20565 Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
cc158403d6
commit
5aa5db7593
6 changed files with 79 additions and 109 deletions
|
|
@ -13,7 +13,7 @@ package gc
|
|||
// to handle optional commas and semicolons before a closing ) or } .
|
||||
|
||||
import (
|
||||
"cmd/internal/obj"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -22,12 +22,12 @@ import (
|
|||
const trace = false // if set, parse tracing can be enabled with -x
|
||||
|
||||
// parse_import parses the export data of a package that is imported.
|
||||
func parse_import(bin *obj.Biobuf, indent []byte) {
|
||||
func parse_import(bin *bufio.Reader, indent []byte) {
|
||||
newparser(bin, indent).import_package()
|
||||
}
|
||||
|
||||
// parse_file parses a single Go source file.
|
||||
func parse_file(bin *obj.Biobuf) {
|
||||
func parse_file(bin *bufio.Reader) {
|
||||
newparser(bin, nil).file()
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ type parser struct {
|
|||
|
||||
// newparser returns a new parser ready to parse from src.
|
||||
// indent is the initial indentation for tracing output.
|
||||
func newparser(src *obj.Biobuf, indent []byte) *parser {
|
||||
func newparser(src *bufio.Reader, indent []byte) *parser {
|
||||
var p parser
|
||||
p.bin = src
|
||||
p.indent = indent
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue