diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2024-06-18 15:34:50 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2024-06-18 15:34:50 -0700 |
| commit | a55350daaf83498b7a237c027ad0dd2377f06fee (patch) | |
| tree | b9f8c43a7b0778a8c2be01e72ecba24484f97a46 /hotline/field.go | |
| parent | 153e2eac3b51a6a426556752fa2c532cfe53f026 (diff) | |
Adopt more fixed size array types for struct fields
Diffstat (limited to 'hotline/field.go')
| -rw-r--r-- | hotline/field.go | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/hotline/field.go b/hotline/field.go index 045e09f..2fcb41a 100644 --- a/hotline/field.go +++ b/hotline/field.go @@ -80,17 +80,11 @@ type requiredField struct { } func NewField(id uint16, data []byte) Field { - idBytes := make([]byte, 2) - binary.BigEndian.PutUint16(idBytes, id) + f := Field{Data: data} + binary.BigEndian.PutUint16(f.ID[:], id) + binary.BigEndian.PutUint16(f.FieldSize[:], uint16(len(data))) - bs := make([]byte, 2) - binary.BigEndian.PutUint16(bs, uint16(len(data))) - - return Field{ - ID: [2]byte(idBytes), - FieldSize: [2]byte(bs), - Data: data, - } + return f } // fieldScanner implements bufio.SplitFunc for parsing byte slices into complete tokens |