mirror of
https://github.com/golang/go
synced 2024-11-23 16:50:06 -07:00
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 <mdempsky@google.com>
This commit is contained in:
parent
6eede325ab
commit
ca4431a384
@ -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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user