diff --git a/command.go b/command.go index 5451ba2..5dd5533 100644 --- a/command.go +++ b/command.go @@ -1073,12 +1073,26 @@ func (cmd *XMessageSliceCmd) String() string { } func (cmd *XMessageSliceCmd) readReply(rd *proto.Reader) error { - v, err := rd.ReadArrayReply(xMessageSliceParser) + var err error + cmd.val, err = readXMessageSlice(rd) + return err +} + +func readXMessageSlice(rd *proto.Reader) ([]XMessage, error) { + n, err := rd.ReadArrayLen() if err != nil { - return err + return nil, err } - cmd.val = v.([]XMessage) - return nil + + msgs := make([]XMessage, n) + for i := 0; i < n; i++ { + var err error + msgs[i], err = readXMessage(rd) + if err != nil { + return nil, err + } + } + return msgs, nil } func readXMessage(rd *proto.Reader) (XMessage, error) { @@ -1112,19 +1126,6 @@ func readXMessage(rd *proto.Reader) (XMessage, error) { }, nil } -// xMessageSliceParser implements proto.MultiBulkParse. -func xMessageSliceParser(rd *proto.Reader, n int64) (interface{}, error) { - msgs := make([]XMessage, n) - for i := int64(0); i < n; i++ { - var err error - msgs[i], err = readXMessage(rd) - if err != nil { - return nil, err - } - } - return msgs, nil -} - // stringInterfaceMapParser implements proto.MultiBulkParse. func stringInterfaceMapParser(rd *proto.Reader, n int64) (interface{}, error) { m := make(map[string]interface{}, n/2) @@ -1195,14 +1196,14 @@ func (cmd *XStreamSliceCmd) readReply(rd *proto.Reader) error { return nil, err } - v, err := rd.ReadArrayReply(xMessageSliceParser) + msgs, err := readXMessageSlice(rd) if err != nil { return nil, err } cmd.val[i] = XStream{ Stream: stream, - Messages: v.([]XMessage), + Messages: msgs, } return nil, nil })