12 Commits

Author SHA1 Message Date
GoWebProd f7b17aa8eb Merge pull request #274 from CAFxX/cafxx-net-buffers
Use net.Buffers in Buffer.DumpTo
2020-03-30 22:46:43 +03:00
GoWebProd 25bafcef7e Merge pull request #272 from CAFxX/patch-1
Make Buffer.EnsureSpace inlineable
2020-03-30 22:45:57 +03:00
Carlo Alberto Ferraris 11e4deeba6 Use net.Buffers in Buffer.DumpTo 2020-03-30 14:45:45 +09:00
Carlo Alberto Ferraris 6f81292b37 wip 2020-02-28 19:33:23 +09:00
Carlo Alberto Ferraris 52fd0e53ca Make Buffer.EnsureSpace inlineable
Split the slow path into a separate function, so that the fast path in EnsureSpace becomes inlineable.

This allows code in jwriter to inline the fast path.
2020-02-28 19:04:54 +09:00
Evgeny Proydakov ffd2765b61 Fixed misspell 2017-03-23 18:25:19 +03:00
Erik Dubbelboer e187266de6 Prevent bugs caused by multiple Close
See: https://github.com/golang/go/issues/19186
When the body isn't fully read and Close is called multiple times we put
the same buffer in the pool multiple times causing it to be reused by
multiple goroutines at the same time.
2017-02-19 06:44:22 +00:00
Sergey Kamardin 7a67b2a713 Merge pull request #77 from erikdubbelboer/readcloser
Add ReadCloser method to jwriter and buffer
2017-02-17 15:26:27 +03:00
Erik Dubbelboer ce0e78724b Add ReadCloser method to jwriter and buffer
When marshalling something as body for a http.Request we can only use
BuildBytes() which always allocates a buffer for our whole body. This
pull request adds a ReadCloser() method which returns an io.ReadCloser
that can be passed as body into http.NewRequest. This ReadCloser will
read from the existing buffs and putBuf them when they are not needed
anymore.
2017-02-17 16:38:15 +08:00
Erik Dubbelboer bb6375f4c8 Allow reusing of buffer in BuildBytes()
This adds an optional parameter to BuildBytes() which allows for reusing
of a byte buffer. Because it's an optional parameter it will not break
backwards compatibility.

This allows people to use a sync.Pool for the buffers used by
BuildBytes() to reduce garbage generation.
2016-11-29 08:59:17 +00:00
Victor Starodub bc7232a0c0 Fixed Buffer.DumpTo() 2016-04-05 01:49:49 +03:00
Victor Starodub 5d497db34c Initial commit. 2016-02-28 03:16:29 +03:00