Problem
Every type not in the Encode() type switch hits reflect.ValueOf(v) which boxes on the heap + getEncoder() sync.Map lookup. Currently covered: nil, string, []byte, int, int64, uint, uint64, bool, float32, float64, time.Duration, time.Time, map[string]string, map[string]interface{}, []interface{}.
Proposal
Add more common types to the switch:
int8, int16, int32
uint8, uint16, uint32
[]string
map[string]bool
[]byte fast path (if not already optimal)
Each addition eliminates reflect.ValueOf boxing + sync.Map lookup for that type.
Files
encode.go — Encode() method type switch
Expected Impact
MEDIUM — depends on Arc's type distribution. Each added type eliminates 1 reflect.ValueOf + 1 sync.Map load per encode call of that type.
Problem
Every type not in the
Encode()type switch hitsreflect.ValueOf(v)which boxes on the heap +getEncoder()sync.Map lookup. Currently covered: nil, string, []byte, int, int64, uint, uint64, bool, float32, float64, time.Duration, time.Time, map[string]string, map[string]interface{}, []interface{}.Proposal
Add more common types to the switch:
int8,int16,int32uint8,uint16,uint32[]stringmap[string]bool[]bytefast path (if not already optimal)Each addition eliminates
reflect.ValueOfboxing + sync.Map lookup for that type.Files
encode.go—Encode()method type switchExpected Impact
MEDIUM — depends on Arc's type distribution. Each added type eliminates 1 reflect.ValueOf + 1 sync.Map load per encode call of that type.