Skip to content

Minor decode-path dispatch: unpackEnum and .custom keys go through generic layers #35

Description

@lalinsky

Two smaller items on the decode path, both from the same review as #31 and #32. Neither is likely to be worth much on its own; grouping them so they can be picked up together or dropped together.

unpackEnum routes through the full integer header switch. It builds an OptionalTagType and calls unpackInt, which runs the whole switch (header) over every int encoding, for what is nearly always a single fixint byte.

The .custom key path uses unpackAny for the key. In unpackStructFromMapBody:

const KeyType = comptime @typeInfo(@TypeOf(Type.msgpackFieldKey)).@"fn".return_type.?;
const key = try unpackAny(reader, allocator, KeyType);

unpackAny re-dispatches on @typeInfo(KeyType) for what is by convention a small integer. Calling unpackInt directly skips a layer. It would also mean msgpackFieldKey returning a non-integer stops silently working, so worth deciding whether that is intended to be supported at all.

For scale: the .as_array format, which removes map framing and keys entirely, decodes only 27% faster than .field_name on message, 13% on document, and 0% on event. Everything here lives inside the remainder, so expect low single digits at best. Measure before and after.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions