[chore] - Update Chunk struct comment (#2317)

* update comment to include information on the importance of struct ordering

* more cute tricks

* remove cute tricks
This commit is contained in:
ahrav
2024-01-20 13:31:27 -08:00
committed by GitHub
parent 8e9bf8aa6d
commit d3d551d24e
2 changed files with 19 additions and 0 deletions
+5
View File
@@ -17,6 +17,11 @@ type (
)
// Chunk contains data to be decoded and scanned along with context on where it came from.
//
// **Important:** The order of the fields in this struct is specifically designed to optimize
// struct alignment and minimize memory usage. Do not change the field order without carefully considering
// the potential impact on memory consumption.
// Ex: https://go.dev/play/p/Azf4a7O-DhC
type Chunk struct {
// Data is the data to decode and scan.
Data []byte
+14
View File
@@ -0,0 +1,14 @@
package sources
import (
"testing"
"unsafe"
"github.com/stretchr/testify/assert"
)
// TestChunkSize ensures that the Chunk struct does not exceed 80 bytes.
func TestChunkSize(t *testing.T) {
t.Parallel()
assert.Equal(t, unsafe.Sizeof(Chunk{}), uintptr(80), "Chunk struct size exceeds 80 bytes")
}