Skip to content

perf: inline PeekCode for byte-slice reader #59

@xe-nvdk

Description

@xe-nvdk

Problem

PeekCode() does ReadByte + UnreadByte through interface dispatch. It is used in many decode paths: map key type detection, binary vs text unmarshaler selection, nil checks, extension decoding, etc.

Proposal

Add a d.s == &d.bsr fast path that peeks directly at d.bsr.data[d.bsr.pos] without any interface method calls (same pattern as hasNilCode).

Files

  • decode.goPeekCode() method

Expected Impact

MEDIUM-HIGH — called frequently during map/slice/extension decode. Eliminates 2 interface dispatches per peek.

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