]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/syntax: add position info for { and } braces
authorRobert Griesemer <gri@golang.org>
Tue, 21 Mar 2017 22:22:13 +0000 (15:22 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 22 Mar 2017 22:36:37 +0000 (22:36 +0000)
commite0329248d5cda9a6a6c1492a2fdeeacd982afc9c
tree9907015e04ff016f1d78588ce2521b1ac925b710
parentec512340148f80aa0be3da90f86043ff535c4081
cmd/compile/internal/syntax: add position info for { and } braces

This change adds position information for { and } braces in the
source. There's a 1.9% increase in memory use for syntax.Nodes,
which is negligible relative to overall compiler memory consumption.

Parsing the std library (using syntax package only) and memory
consumption before this change (fastest of 5 runs):

  $ go test -run StdLib -fast
  parsed 1516827 lines (3392 files) in 780.612335ms (1943124 lines/s)
  allocated 379.903Mb (486.673Mb/s)

After this change (fastest of 5 runs):

  $ go test -run StdLib -fast
  parsed 1517022 lines (3394 files) in 793.487886ms (1911840 lines/s)
  allocated 387.086Mb (267B/line, 487.828Mb/s)

While not an exact apples-to-apples comparison (the syntax package
has changed and is also parsed), the overall impact is small.

Also: Small improvements to nodes_test.go.

Change-Id: Ib8a7f90bbe79de33d83684e33b1bf8dbc32e644a
Reviewed-on: https://go-review.googlesource.com/38435
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/syntax/nodes.go
src/cmd/compile/internal/syntax/nodes_test.go
src/cmd/compile/internal/syntax/parser.go
src/cmd/compile/internal/syntax/parser_test.go