Skip to content

Commit 91f53e1

Browse files
committed
refactor a bit
1 parent 9f56c3a commit 91f53e1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pkg/demoinfocs/sendtables2/serializer.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strings"
66
)
77

8-
type FieldIndex struct {
8+
type fieldIndex struct {
99
index int
1010
field *field
1111
}
@@ -14,7 +14,7 @@ type serializer struct {
1414
name string
1515
version int32
1616
fields []*field
17-
fieldIndexes map[string]*FieldIndex
17+
fieldIndexes map[string]*fieldIndex
1818
}
1919

2020
func (s *serializer) id() string {
@@ -75,12 +75,15 @@ func serializerId(name string, version int32) string {
7575
}
7676

7777
func (s *serializer) addField(f *field) {
78+
newFieldIndex := len(s.fields)
7879
s.fields = append(s.fields, f)
80+
7981
if s.fieldIndexes == nil {
80-
s.fieldIndexes = make(map[string]*FieldIndex)
82+
s.fieldIndexes = make(map[string]*fieldIndex)
8183
}
82-
s.fieldIndexes[f.varName] = &FieldIndex{
83-
index: len(s.fields) - 1,
84+
85+
s.fieldIndexes[f.varName] = &fieldIndex{
86+
index: newFieldIndex,
8487
field: f,
8588
}
8689
}

0 commit comments

Comments
 (0)