Skip to content

hashCode cache #22

@modulovalue

Description

@modulovalue

Hello @isoos!

(I hope you don't mind all the issues. Having an efficient bitset in Dart has been on my TODO list for a looong time :), and your work is the best starting point that I've been able to find so far.)

One of my BitArray-related bottlenecks appears to be related to hashCode calculations:

Screenshot 2023-12-23 at 02 41 26

What do you think about having a hashCode cache on BitArray? That is, on each mutation to the underlying BitArray buffer we'd invalidate the current hashCode (i.e., _hashCodeCache = null) and on each invocation of hashCode we'd set it to the current hashCode if it is not present (i.e., _hashCodeCache ??= currentHashCode).

What do you think?

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