aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/nodes_test.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_test.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_test.go')
-rw-r--r--src/cmd/compile/internal/syntax/nodes_test.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/syntax/nodes_test.go b/src/cmd/compile/internal/syntax/nodes_test.go
index 935a1096c6..ea446235fa 100644
--- a/src/cmd/compile/internal/syntax/nodes_test.go
+++ b/src/cmd/compile/internal/syntax/nodes_test.go
@@ -261,23 +261,23 @@ func TestPos(t *testing.T) {
)
testPos(t, stmts, "package p; func _() { ", "; }",
- func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body[0] },
+ func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body.List[0] },
)
testPos(t, ranges, "package p; func _() { for ", " {} }",
- func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body[0].(*ForStmt).Init.(*RangeClause) },
+ func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body.List[0].(*ForStmt).Init.(*RangeClause) },
)
testPos(t, guards, "package p; func _() { switch ", " {} }",
- func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body[0].(*SwitchStmt).Tag.(*TypeSwitchGuard) },
+ func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body.List[0].(*SwitchStmt).Tag.(*TypeSwitchGuard) },
)
testPos(t, cases, "package p; func _() { switch { ", " } }",
- func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body[0].(*SwitchStmt).Body[0] },
+ func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body.List[0].(*SwitchStmt).Body[0] },
)
testPos(t, comms, "package p; func _() { select { ", " } }",
- func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body[0].(*SelectStmt).Body[0] },
+ func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body.List[0].(*SelectStmt).Body[0] },
)
}