cmd/compile: replace aindex with typArray

aindex is overkill when it's only ever used with known integer
constants, so just use typArray directly instead.

Change-Id: I43fc14e604172df859b3ad9d848d219bbe48e434
Reviewed-on: https://go-review.googlesource.com/30979
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Matthew Dempsky 2016-10-12 23:28:36 -07:00
parent 1af769da82
commit 032e2bd1eb
2 changed files with 7 additions and 31 deletions

View file

@ -475,30 +475,6 @@ func nodbool(b bool) *Node {
return c
}
func aindex(b *Node, t *Type) *Type {
hasbound := false
var bound int64
b = typecheck(b, Erv)
if b != nil {
switch consttype(b) {
default:
yyerror("array bound must be an integer expression")
case CTINT, CTRUNE:
hasbound = true
bound = b.Int64()
if bound < 0 {
yyerror("array bound must be non negative")
}
}
}
if !hasbound {
return typSlice(t)
}
return typArray(t, bound)
}
// treecopy recursively copies n, with the exception of
// ONAME, OLITERAL, OTYPE, and non-iota ONONAME leaves.
// Copies of iota ONONAME nodes are assigned the current