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:
David Crawshaw 2016-03-11 13:39:20 -05:00
parent cc158403d6
commit 5aa5db7593
6 changed files with 79 additions and 109 deletions

View file

@ -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