Skip to content

Optimize internal calls to UnmarshalCBOR() for ByteString, RawTag, and SimpleValue #646

@fxamacker

Description

@fxamacker

Problem

Currently, the unreleased changes in PR #636 and #645 cause the input data to be checked twice when UnmarshalCBOR() is called internally.

UnmarshalCBOR() checks input data because it can be called by user apps providing bad data. However, the codec already checks input data before internally calling UnmarshalCBOR() so the 2nd check is redundant.

Solution

Optimize by making the codec no longer directly call UnmarshalCBOR() if the private unmarshalCBOR() is implemented by the type:

  • Internally, the codec will call the private unmarshalCBOR() to avoid validating data twice.
  • MarshalCBOR() will be a simple wrapper that checks data for validity before calling the private unmarshalCBOR().

Status

This optimization is being tested locally. It will be merged and fuzzed for longer durations before release v2.7.1 and v2.8.0.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions