MCPcopy
hub / github.com/coder/websocket / init

Method init

compress.go:192–208  ·  view source on GitHub ↗
(n int)

Source from the content-addressed store, hash-verified

190}
191
192func (sw *slidingWindow) init(n int) {
193 if sw.buf != nil {
194 return
195 }
196
197 if n == 0 {
198 n = 32768
199 }
200
201 p := slidingWindowPool(n)
202 sw2, ok := p.Get().(*slidingWindow)
203 if ok {
204 *sw = *sw2
205 } else {
206 sw.buf = make([]byte, 0, n)
207 }
208}
209
210func (sw *slidingWindow) close() {
211 sw.buf = sw.buf[:0]

Callers 1

Test_slidingWindowFunction · 0.95

Calls 1

slidingWindowPoolFunction · 0.85

Tested by 1

Test_slidingWindowFunction · 0.76