File tree Expand file tree Collapse file tree 1 file changed +18
-20
lines changed Expand file tree Collapse file tree 1 file changed +18
-20
lines changed Original file line number Diff line number Diff line change @@ -69,29 +69,27 @@ func (r *Reader) ReadLine() ([]byte, error) {
69
69
// - there is a pending read error;
70
70
// - or line does not end with \r\n.
71
71
func (r * Reader ) readLine () ([]byte , error ) {
72
- var s []byte
73
- multi := false
74
- for {
75
- b , err := r .rd .ReadSlice ('\n' )
76
- if err != nil {
77
- // in case the end of the buffer is not reached
78
- if err == bufio .ErrBufferFull {
79
- s = append (s , b ... )
80
- multi = true
81
- continue
82
- } else {
83
- return nil , err
84
- }
85
- }
86
- if len (b ) <= 2 || b [len (b )- 1 ] != '\n' || b [len (b )- 2 ] != '\r' {
87
- return nil , fmt .Errorf ("redis: invalid reply: %q" , b )
72
+ b , err := r .rd .ReadSlice ('\n' )
73
+ if err != nil {
74
+ if err != bufio .ErrBufferFull {
75
+ return nil , err
88
76
}
89
- if multi {
90
- b = append (s , b ... )
77
+
78
+ full := make ([]byte , len (b ))
79
+ copy (full , b )
80
+
81
+ b , err = r .rd .ReadBytes ('\n' )
82
+ if err != nil {
83
+ return nil , err
91
84
}
92
- b = b [:len (b )- 2 ]
93
- return b , nil
85
+
86
+ full = append (full , b ... )
87
+ b = full
88
+ }
89
+ if len (b ) <= 2 || b [len (b )- 1 ] != '\n' || b [len (b )- 2 ] != '\r' {
90
+ return nil , fmt .Errorf ("redis: invalid reply: %q" , b )
94
91
}
92
+ return b [:len (b )- 2 ], nil
95
93
}
96
94
97
95
func (r * Reader ) ReadReply (m MultiBulkParse ) (interface {}, error ) {
You can’t perform that action at this time.
0 commit comments