@@ -7,11 +7,17 @@ import (
77 st "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/sendtables"
88)
99
10+ type fpNameTreeCache struct {
11+ next map [int ]* fpNameTreeCache
12+ name string
13+ }
14+
1015type class struct {
1116 classId int32
1217 name string
1318 serializer * serializer
1419 createdHandlers []st.EntityCreatedHandler
20+ fpNameCache * fpNameTreeCache
1521}
1622
1723func (c * class ) ID () int {
@@ -72,7 +78,27 @@ func (c *class) collectFieldsEntries(fields []*field, prefix string) []string {
7278}
7379
7480func (c * class ) getNameForFieldPath (fp * fieldPath ) string {
75- return strings .Join (c .serializer .getNameForFieldPath (fp , 0 ), "." )
81+ currentCacheNode := c .fpNameCache
82+
83+ for i := 0 ; i <= fp .last ; i ++ {
84+ if currentCacheNode .next == nil {
85+ currentCacheNode .next = make (map [int ]* fpNameTreeCache )
86+ }
87+
88+ pos := fp .path [i ]
89+ next , exists := currentCacheNode .next [pos ]
90+ if ! exists {
91+ next = & fpNameTreeCache {}
92+ currentCacheNode .next [pos ] = next
93+ }
94+ currentCacheNode = next
95+ }
96+
97+ if currentCacheNode .name == "" {
98+ currentCacheNode .name = strings .Join (c .serializer .getNameForFieldPath (fp , 0 ), "." )
99+ }
100+
101+ return currentCacheNode .name
76102}
77103
78104func (c * class ) getTypeForFieldPath (fp * fieldPath ) * fieldType {
0 commit comments