1
0
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:
源文雨
2025-04-04 01:26:37 +09:00
parent 82c6136782
commit b5992574ec
16 changed files with 83 additions and 28 deletions

View File

@@ -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()
}