]> 127.0.0.1 Git - part/.git/commitdiff
1 v0.28.20231215215733
authorqydysky <qydysky@foxmail.com>
Fri, 15 Dec 2023 21:49:47 +0000 (05:49 +0800)
committerqydysky <qydysky@foxmail.com>
Fri, 15 Dec 2023 21:49:47 +0000 (05:49 +0800)
slice/Blocks.go

index 39c907bc66a7357ee5906eaddc1e66eedf3b87e2..34acc57ffe3438c50299e46a074f3cc379ac9f0b 100644 (file)
@@ -44,9 +44,8 @@ func NewBlocks[T any](blockSize int, blockNum int) BlocksI[T] {
 func (t *blocks[T]) Get() ([]T, func(), error) {
        select {
        case offset := <-t.free:
-               offset *= t.size
-               return t.buf[offset : offset+t.size], func() {
-                       clear(t.buf[offset : offset+t.size])
+               return t.buf[offset*t.size : (offset+1)*t.size], func() {
+                       clear(t.buf[offset*t.size : (offset+1)*t.size])
                        t.free <- offset
                }, nil
        default: