1
0
mirror of https://github.com/golang/go synced 2024-11-19 09:54:49 -07:00

reflect: use SelectDir instead of uintptr in runtimeSelect

And fix the wrong comment.

Initially found this because the comment was wrong about the possible
values. Then noticed that there doesn't seem to be any reason to use
uintptr over SelectDir.

Change-Id: I4f9f9640e49d89e558ed00bd99e57dab890785f5
Reviewed-on: https://go-review.googlesource.com/20655
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Dominik Honnef 2016-03-14 01:59:22 +01:00 committed by Brad Fitzpatrick
parent 43ed65f869
commit 368507bb6f

View File

@ -1876,7 +1876,7 @@ func Copy(dst, src Value) int {
// A runtimeSelect is a single case passed to rselect.
// This must match ../runtime/select.go:/runtimeSelect
type runtimeSelect struct {
dir uintptr // 0, SendDir, or RecvDir
dir SelectDir // SelectSend, SelectRecv or SelectDefault
typ *rtype // channel type
ch unsafe.Pointer // channel
val unsafe.Pointer // ptr to data (SendDir) or ptr to receive buffer (RecvDir)
@ -1939,7 +1939,7 @@ func Select(cases []SelectCase) (chosen int, recv Value, recvOK bool) {
haveDefault := false
for i, c := range cases {
rc := &runcases[i]
rc.dir = uintptr(c.Dir)
rc.dir = c.Dir
switch c.Dir {
default:
panic("reflect.Select: invalid Dir")
@ -2002,7 +2002,7 @@ func Select(cases []SelectCase) (chosen int, recv Value, recvOK bool) {
}
chosen, recvOK = rselect(runcases)
if runcases[chosen].dir == uintptr(SelectRecv) {
if runcases[chosen].dir == SelectRecv {
tt := (*chanType)(unsafe.Pointer(runcases[chosen].typ))
t := tt.elem
p := runcases[chosen].val