Skip to content

perf(encode): add map[string]string fast path in Encode() type switch#52

Merged
xe-nvdk merged 1 commit intov6from
perf/encode-fastpaths
Mar 3, 2026
Merged

perf(encode): add map[string]string fast path in Encode() type switch#52
xe-nvdk merged 1 commit intov6from
perf/encode-fastpaths

Conversation

@xe-nvdk
Copy link
Member

@xe-nvdk xe-nvdk commented Mar 3, 2026

Summary

  • Adds case map[string]string: to Encode() type switch, bypassing reflect.ValueOf + getEncoder dispatch
  • Adds encodeMapStringString method that operates directly on the concrete type

Benchmark Results

MapStringString: 192 ns -> 164 ns (-15%)

Test plan

  • All existing tests pass
  • Benchmarks show 15% improvement for map[string]string encoding

Adds a direct type assertion case for map[string]string in Encode(),
bypassing reflect.ValueOf + getEncoder dispatch. Also adds
encodeMapStringString method that operates on the concrete type
without reflection.

Benchmark: MapStringString 192 ns -> 164 ns (-15%)
@xe-nvdk xe-nvdk merged commit 0249004 into v6 Mar 3, 2026
3 checks passed
@xe-nvdk xe-nvdk deleted the perf/encode-fastpaths branch March 3, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant