Skip to content

Optimize AccountCode equality comparison performance #2429

@PivasDesant

Description

@PivasDesant

The PartialEq implementation for AccountCode compares the entire MastForest, which is slow for large code structures.

Since commitment uniquely identifies the account code (and is already used for Ord), we should use it for equality checks instead of comparing the full MastForest.

Current code:

self.mast == other.mast && self.procedures == other.procedures

Expected change:

Compare by commitment and procedures instead of mast and procedures.

There's already a TODO comment in the code suggesting this optimization (line 234). This should improve performance without changing correctness, since commitment is deterministic and uniquely identifies the code interface.

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