From d379abe190d5ca3715642acec248498637629d53 Mon Sep 17 00:00:00 2001 From: liaohanqin Date: Wed, 27 Oct 2021 09:42:06 +0800 Subject: [PATCH] fix: remove redundant type conversions --- transport_unix.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/transport_unix.go b/transport_unix.go index 2212e7f..0a8c712 100644 --- a/transport_unix.go +++ b/transport_unix.go @@ -154,17 +154,15 @@ func (t *unixTransport) ReadMessage() (*Message, error) { // substitute the values in the message body (which are indices for the // array receiver via OOB) with the actual values for i, v := range msg.Body { - switch v.(type) { + switch index := v.(type) { case UnixFDIndex: - j := v.(UnixFDIndex) - if uint32(j) >= unixfds { + if uint32(index) >= unixfds { return nil, InvalidMessageError("invalid index for unix fd") } - msg.Body[i] = UnixFD(fds[j]) + msg.Body[i] = UnixFD(fds[index]) case []UnixFDIndex: - idxArray := v.([]UnixFDIndex) - fdArray := make([]UnixFD, len(idxArray)) - for k, j := range idxArray { + fdArray := make([]UnixFD, len(index)) + for k, j := range index { if uint32(j) >= unixfds { return nil, InvalidMessageError("invalid index for unix fd") }