aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/nodes.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2017-03-21 22:23:15 -0700
committerRobert Griesemer <gri@golang.org>2017-03-22 22:37:08 +0000
commitb5f81eae17b68c9a34d23dcf4669e3d879781b35 (patch)
tree3a8827c045d3d219bfd306318429d834ca575887 /src/cmd/compile/internal/syntax/nodes.go
parente0329248d5cda9a6a6c1492a2fdeeacd982afc9c (diff)
downloadgo-b5f81eae17b68c9a34d23dcf4669e3d879781b35.tar.gz
go-b5f81eae17b68c9a34d23dcf4669e3d879781b35.zip
cmd/compile/internal/syntax: replace inlined statement lists with syntax.BlockStmt
This simplifies the code and removes a premature optimization. It increases the amount of allocated syntax.Node space by ~0.4% for parsing all of std lib, which is negligible. Before the change (best 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) After the change (best of 5 runs): $ go test -run StdLib -fast parsed 1516911 lines (3392 files) in 805.028655ms (1884294 lines/s) allocated 388.466Mb (268B/line, 482.549Mb/s) Change-Id: Id19d6210fdc62393862ba3b04913352d95c599be Reviewed-on: https://go-review.googlesource.com/38439 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/nodes.go')
-rw-r--r--src/cmd/compile/internal/syntax/nodes.go46
1 files changed, 21 insertions, 25 deletions
diff --git a/src/cmd/compile/internal/syntax/nodes.go b/src/cmd/compile/internal/syntax/nodes.go
index a99cb008f2..4fb50b1f4a 100644
--- a/src/cmd/compile/internal/syntax/nodes.go
+++ b/src/cmd/compile/internal/syntax/nodes.go
@@ -97,13 +97,12 @@ type (
// func Receiver Name Type { Body }
// func Receiver Name Type
FuncDecl struct {
- Attr map[string]bool // go:attr map
- Recv *Field // nil means regular function
- Name *Name
- Type *FuncType
- Body []Stmt // nil means no body (forward declaration)
- Lbrace, Rbrace src.Pos
- Pragma Pragma // TODO(mdempsky): Cleaner solution.
+ Attr map[string]bool // go:attr map
+ Recv *Field // nil means regular function
+ Name *Name
+ Type *FuncType
+ Body *BlockStmt // nil means no body (forward declaration)
+ Pragma Pragma // TODO(mdempsky): Cleaner solution.
decl
}
)
@@ -141,10 +140,10 @@ type (
// Type { ElemList[0], ElemList[1], ... }
CompositeLit struct {
- Type Expr // nil means no literal type
- ElemList []Expr
- NKeys int // number of elements with keys
- Lbrace, Rbrace src.Pos
+ Type Expr // nil means no literal type
+ ElemList []Expr
+ NKeys int // number of elements with keys
+ Rbrace src.Pos
expr
}
@@ -156,9 +155,8 @@ type (
// func Type { Body }
FuncLit struct {
- Type *FuncType
- Body []Stmt
- Lbrace, Rbrace src.Pos
+ Type *FuncType
+ Body *BlockStmt
expr
}
@@ -323,7 +321,7 @@ type (
}
BlockStmt struct {
- Body []Stmt
+ List []Stmt
Rbrace src.Pos
stmt
}
@@ -367,20 +365,18 @@ type (
}
IfStmt struct {
- Init SimpleStmt
- Cond Expr
- Then []Stmt
- Lbrace, Rbrace src.Pos // of Then branch
- Else Stmt // either *IfStmt or *BlockStmt
+ Init SimpleStmt
+ Cond Expr
+ Then *BlockStmt
+ Else Stmt // either *IfStmt or *BlockStmt
stmt
}
ForStmt struct {
- Init SimpleStmt // incl. *RangeClause
- Cond Expr
- Post SimpleStmt
- Body []Stmt
- Lbrace, Rbrace src.Pos
+ Init SimpleStmt // incl. *RangeClause
+ Cond Expr
+ Post SimpleStmt
+ Body *BlockStmt
stmt
}