Skip to content

Specialize BitArray set ops to improve performance #18

Description

@modulovalue

Hey @isoos,

I think there's a simple way to improve the performance of all the set operations of BitArray on other BitArrays by specializing them to take a BitArray and using that knowledge to avoid using iterators.

That is, I've observed that we can be more efficient if we replace the following:

  // ... and and/andNot/xor
  void or(BitSet set) {
    final iter = set.asUint32Iterable().iterator;
    for (var i = 0; i < _data.length && iter.moveNext(); i++) {
      _data[i] |= iter.current;
    }
  }

with

  // ... and and/andNot/xor
  void or(BitArray set) {
    final Uint32List data2 = set._data;
    for (var i = 0; i < _data.length && i < data2.length; i++) {
      _data[i] |= data2[i];
    }
  }

I'm not proposing to replace the existing set operations, but to add new ones that work on BitArrays only.

What do you think?

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