Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for copyBufPool (0.1 sec)

  1. internal/ioutil/ioutil.go

    	return &SkipReader{r, n}
    }
    
    var copyBufPool = sync.Pool{
    	New: func() interface{} {
    		b := make([]byte, 32*1024)
    		return &b
    	},
    }
    
    // Copy is exactly like io.Copy but with reusable buffers.
    func Copy(dst io.Writer, src io.Reader) (written int64, err error) {
    	bufp := copyBufPool.Get().(*[]byte)
    	buf := *bufp
    	defer copyBufPool.Put(bufp)
    
    	return io.CopyBuffer(dst, src, buf)
    }
    
    Registered: Sun Jun 16 00:44:34 UTC 2024
    - Last Modified: Wed May 22 23:07:14 UTC 2024
    - 10.2K bytes
    - Viewed (0)
  2. src/net/http/server.go

    )
    
    const copyBufPoolSize = 32 * 1024
    
    var copyBufPool = sync.Pool{New: func() any { return new([copyBufPoolSize]byte) }}
    
    func getCopyBuf() []byte {
    	return copyBufPool.Get().(*[copyBufPoolSize]byte)[:]
    }
    func putCopyBuf(b []byte) {
    	if len(b) != copyBufPoolSize {
    		panic("trying to put back buffer of the wrong size in the copyBufPool")
    	}
    	copyBufPool.Put((*[copyBufPoolSize]byte)(b))
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Jun 07 17:57:01 UTC 2024
    - 123.4K bytes
    - Viewed (0)
Back to top