From ca4431a3846de4b1c5cf2388ca22d915f510f7fd Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 21 Oct 2016 16:07:47 -0700 Subject: [PATCH] cmd/compile: avoid one symbol lookup for qualified identifiers For -newparser only. Change-Id: I0eaa05035df11734e2bda7ad456b9b30485d9465 Reviewed-on: https://go-review.googlesource.com/31718 Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/gc/noder.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/cmd/compile/internal/gc/noder.go b/src/cmd/compile/internal/gc/noder.go index 65f39b35063..11fdde1bbcc 100644 --- a/src/cmd/compile/internal/gc/noder.go +++ b/src/cmd/compile/internal/gc/noder.go @@ -373,13 +373,11 @@ func (p *noder) expr(expr syntax.Expr) *Node { case *syntax.SelectorExpr: // parser.new_dotname obj := p.expr(expr.X) - sel := p.name(expr.Sel) if obj.Op == OPACK { - s := restrictlookup(sel.Name, obj.Name.Pkg) obj.Used = true - return oldname(s) + return oldname(restrictlookup(expr.Sel.Value, obj.Name.Pkg)) } - return p.setlineno(expr, nodSym(OXDOT, obj, sel)) + return p.setlineno(expr, nodSym(OXDOT, obj, p.name(expr.Sel))) case *syntax.IndexExpr: return p.nod(expr, OINDEX, p.expr(expr.X), p.expr(expr.Index)) case *syntax.SliceExpr: @@ -535,7 +533,6 @@ func (p *noder) packname(expr syntax.Expr) *Sym { return name case *syntax.SelectorExpr: name := p.name(expr.X.(*syntax.Name)) - s := p.name(expr.Sel) var pkg *Pkg if name.Def == nil || name.Def.Op != OPACK { yyerror("%v is not a package", name) @@ -544,7 +541,7 @@ func (p *noder) packname(expr syntax.Expr) *Sym { name.Def.Used = true pkg = name.Def.Name.Pkg } - return restrictlookup(s.Name, pkg) + return restrictlookup(expr.Sel.Value, pkg) } panic(fmt.Sprintf("unexpected packname: %#v", expr)) }