mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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:
parent
1af769da82
commit
032e2bd1eb
2 changed files with 7 additions and 31 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue