]> 127.0.0.1 Git - part/.git/commitdiff
Improve v0.23.6
authorqydysky <32743305+qydysky@users.noreply.github.com>
Thu, 2 Mar 2023 16:35:15 +0000 (00:35 +0800)
committerqydysky <32743305+qydysky@users.noreply.github.com>
Thu, 2 Mar 2023 16:35:15 +0000 (00:35 +0800)
slice/Slice.go

index 0120c3eeefa4d00d230c5c7377c7ba482fd68c3b..2a07109216124a03e29d5ddac1df72fbffea08b1 100644 (file)
@@ -65,17 +65,11 @@ func (t *Buf[T]) Append(data []T) error {
        if t.maxsize != 0 && len(t.buf)+len(data) > t.maxsize {
                return errors.New("超出设定maxsize")
        } else if len(t.buf) == 0 {
-               if t.maxsize == 0 {
-                       t.buf = make([]T, len(data))
-               } else {
-                       t.buf = make([]T, len(data), t.maxsize)
-               }
+               t.buf = make([]T, len(data))
        } else {
                diff := len(t.buf) - t.bufsize - len(data)
                if diff < 0 {
                        t.buf = append(t.buf, make([]T, -diff)...)
-               } else {
-                       t.buf = t.buf[:t.bufsize+len(data)]
                }
        }
        t.bufsize += copy(t.buf[t.bufsize:], data)