File tree 1 file changed +12
-7
lines changed
1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -99,21 +99,26 @@ func (c *Conn) ReadPacketReuseMem(dst []byte) ([]byte, error) {
99
99
}
100
100
101
101
readBytes := buf .Bytes ()
102
- readSize := len (readBytes ) + len ( dst )
103
- result := make ( []byte , 0 , readSize )
102
+ readSize := len (readBytes )
103
+ var result []byte
104
104
if len (dst ) > 0 {
105
- result = append (result , dst ... )
106
- result = append (result , readBytes ... )
105
+ result = append (dst , readBytes ... )
106
+ // if read block is big, do not cache buf any more
107
+ if readSize > utils .TooBigBlockSize {
108
+ buf = nil
109
+ }
107
110
108
111
} else {
109
- if readSize <= utils .TooBigBlockSize {
110
- result = append (result , readBytes ... )
111
- } else {
112
+ if readSize > utils .TooBigBlockSize {
112
113
// if read block is big, use read block as result and do not cache buf any more
113
114
result = readBytes
114
115
buf = nil
116
+
117
+ } else {
118
+ result = append (dst , readBytes ... )
115
119
}
116
120
}
121
+
117
122
return result , nil
118
123
}
119
124
You can’t perform that action at this time.
0 commit comments