allegro / allegro/bigcache

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

Ouverte
#404 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
enhancement
Langage dominant
Go
Étoiles
8.2k
Forks
614
Merge moyen
5 j 12 h
PR mergées (30 j)
1

Description

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

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.