Skip to content

Optimise TokenError performance by boxing StateInvariantError #255

Description

@rvagg

The TokenError enum in the FRC46 library contains a large StateInvariantError variant (192+ bytes) that triggers clippy warnings about large error types. I believe this impacts performance because Result<T, TokenError> types are frequently used throughout the FRC46 library so the warning is probably worth paying attention to.

Proposed Solution

Box the StateInvariant variant to reduce TokenError size:

#[derive(Error, Debug)]
pub enum TokenError {
    // ... other variants unchanged
    #[error("error in state invariants {0}")]
    StateInvariant(Box<StateInvariantError>),  // Box this variant
}

I think the public impact should be fairly minimal and won't change the exit code behaviour of FRC46 implementations.

But, I'm not entirely sure yet, which is why I'm not doing this right now!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions