allegro / allegro/bigcache

is it possible to provide an 'unsafe' way to get internal []byte and avoid mem copy?

Đang mở
#404 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Go
Star
8.2k
Fork
614
Merge trung bình
5 ngày 12 giờ
Pull request đã merge (30 ngày)
1

Mô tả

**What is the issue you are having?**

In some scenarios, the data retrieved from the cache will not be modified and could be directly returned.

**What is BigCache doing that it shouldn't?**
```go
func readEntry(data []byte) []byte {
length := binary.LittleEndian.Uint16(data[timestampSizeInBytes+hashSizeInBytes:])

// copy on read
dst := make([]byte, len(data)-int(headersSizeInBytes+length))
copy(dst, data[headersSizeInBytes+length:])

return dst
}
```
to be --- to recycle the 'dst'
```go
func readEntry(dst, data []byte) []byte {
length := binary.LittleEndian.Uint16(data[timestampSizeInBytes+hashSizeInBytes:])

copy(dst, data[headersSizeInBytes+length:])

return dst
}
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.