]> 127.0.0.1 Git - part/.git/commitdiff
Remove v0.23.14
authorqydysky <32743305+qydysky@users.noreply.github.com>
Sat, 4 Mar 2023 16:16:10 +0000 (00:16 +0800)
committerqydysky <32743305+qydysky@users.noreply.github.com>
Sat, 4 Mar 2023 16:16:10 +0000 (00:16 +0800)
slice/Slice.go
slice/Slice_test.go

index 755b7a2af531a24618ba0fea070ac4f6a9c8431b..5d98d42edf972444ef54519915aa6a19f1d7c359 100644 (file)
@@ -159,19 +159,3 @@ func (t *Buf[T]) GetCopyBuf() (buf []T) {
        copy(buf, t.buf[:t.bufsize])
        return
 }
-
-// *Need to lock when processing buf or Make sure buf only processing by AppendBufCopy
-//
-// *Not use b = make() to avoid pointer change
-func (t *Buf[T]) AppendBufCopy(buf *[]T) {
-       t.l.RLock()
-       defer t.l.RUnlock()
-
-       origin := len(*buf)
-       if origin == 0 {
-               *buf = make([]T, t.bufsize)
-       } else {
-               *buf = append(*buf, make([]T, t.bufsize)...)
-       }
-       copy((*buf)[origin:], t.buf[:t.bufsize])
-}
index c610c685680ab6d75805e814e071c7ecb93b7c6b..a093095d23f703089c00917b34c46626c499016c 100644 (file)
@@ -3,7 +3,6 @@ package part
 import (
        "bytes"
        "testing"
-       "unsafe"
 )
 
 func TestXxx(t *testing.T) {
@@ -80,32 +79,3 @@ func TestXxx2(t *testing.T) {
                t.Fatal()
        }
 }
-
-func TestXxx3(t *testing.T) {
-       var c = New[byte]()
-       var b []byte
-       var bp = unsafe.Pointer(&b)
-       c.Append([]byte("12345"))
-       c.Append([]byte("67890"))
-       c.AppendBufCopy(&b)
-       c.Reset()
-       if !bytes.Equal(b, []byte("1234567890")) {
-               t.Fatal(string(b))
-       }
-       b = []byte{}
-       c.Append([]byte("abc"))
-       c.Append([]byte("defg"))
-       c.AppendBufCopy(&b)
-       c.Reset()
-       if !bytes.Equal(b, []byte("abcdefg")) || unsafe.Pointer(&b) != bp {
-               t.Fatal()
-       }
-       b = b[:0]
-       c.Append([]byte("akjsdhfaksdjhf"))
-       c.Append([]byte("9834719203857"))
-       c.AppendBufCopy(&b)
-       c.Reset()
-       if !bytes.Equal(b, []byte("akjsdhfaksdjhf9834719203857")) || unsafe.Pointer(&b) != bp {
-               t.Fatal()
-       }
-}