Skip to content

perf: Decode() type switch for common scalar pointers #64

@xe-nvdk

Description

@xe-nvdk

Problem

On the decode side, common patterns like `Unmarshal(b, &myString)` or `Unmarshal(b, &myInt64)` go through `reflect.ValueOf(v)` + full decoder dispatch. There is already a fast path for `*interface{}` but not for other common pointer types.

Proposal

Add fast paths in `Decode()` for:

  • `*string`
  • `*int64`, `*int`
  • `*uint64`, `*uint`
  • `*float64`
  • `*bool`
  • `*[]byte`

Each avoids `reflect.ValueOf` boxing + `getDecoder` sync.Map lookup.

Files

  • `decode.go` — `Decode()` method

Expected Impact

MEDIUM — depends on how often Arc decodes into scalar pointers vs structs. Eliminates 1 reflect.ValueOf + 1 sync.Map load per scalar decode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance optimization

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions