mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-21 11:02:42 +08:00
optimize(orbyte): use manual destroy
This commit is contained in:
@@ -11,10 +11,12 @@ import (
|
||||
// Writer 写入
|
||||
type Writer pbuf.OBuffer
|
||||
|
||||
func NewWriterF(f func(writer *Writer)) pbuf.Bytes {
|
||||
func NewWriterF(f func(writer *Writer)) []byte {
|
||||
w := SelectWriter()
|
||||
f(w)
|
||||
return w.ToBytes()
|
||||
b := w.ToBytes().Copy()
|
||||
w.Destroy()
|
||||
return b.Trans()
|
||||
}
|
||||
|
||||
func (w *Writer) P(f func(*pbuf.Buffer)) *Writer {
|
||||
@@ -64,3 +66,7 @@ func (w *Writer) WriteUInt64(v uint64) {
|
||||
func (w *Writer) ToBytes() pbuf.Bytes {
|
||||
return pbuf.BufferItemToBytes((*pbuf.OBuffer)(w))
|
||||
}
|
||||
|
||||
func (w *Writer) Destroy() {
|
||||
(*pbuf.OBuffer)(w).ManualDestroy()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user