allegro / allegro/bigcache

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

オープン
#404 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Go
スター
8.2k
フォーク
614
平均マージ
5日 12時間
マージ済み PR(30日)
1

説明

**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
}
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。