Skip to content

Commit 0fa18af

Browse files
committed
Store only the index in the cache instead of the whole StructField
1 parent 01b16d4 commit 0fa18af

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

vm/runtime/runtime.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ func Fetch(from, i any) any {
7676
t: t,
7777
f: fieldName,
7878
}
79-
if fi, ok := fieldCache.Load(key); ok {
80-
field := fi.(*reflect.StructField)
81-
return v.FieldByIndex(field.Index).Interface()
79+
if cv, ok := fieldCache.Load(key); ok {
80+
return v.FieldByIndex(cv.([]int)).Interface()
8281
}
8382
field, ok := t.FieldByNameFunc(func(name string) bool {
8483
field, _ := t.FieldByName(name)
@@ -94,7 +93,7 @@ func Fetch(from, i any) any {
9493
if ok {
9594
value := v.FieldByIndex(field.Index)
9695
if value.IsValid() {
97-
fieldCache.Store(key, &field)
96+
fieldCache.Store(key, field.Index)
9897
return value.Interface()
9998
}
10099
}

0 commit comments

Comments
 (0)