[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:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
Reference in New Issue
Block a user