From 4ebfc3e836e5ec24fd35b8e78d3f1118bedb0ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Tue, 25 Feb 2025 16:53:38 +0900 Subject: [PATCH] feat(pbuf): add api HasInit --- pbuf/bytes.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pbuf/bytes.go b/pbuf/bytes.go index 433a8e8..05267f1 100644 --- a/pbuf/bytes.go +++ b/pbuf/bytes.go @@ -41,6 +41,12 @@ func (bufferPool BufferPool) ParseBytes(b ...byte) Bytes { return Bytes{buf: buf, dat: buf.Pointer().Bytes()} } +// HasInit whether this Bytes is made by pool or +// just declared. +func (b Bytes) HasInit() bool { + return b.buf != nil +} + // Trans please refer to Item.Trans(). func (b Bytes) Trans() (tb Bytes) { tb.buf = b.buf.Trans()