diff options
author | Aina Niemetz <aina.niemetz@gmail.com> | 2021-03-19 10:28:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-19 17:28:14 +0000 |
commit | 58e219362b2e9a7d7b9b9b526760c392cd50e878 (patch) | |
tree | edc5b6e8f4307942a914d13c218197328c8cb6bf /src/util/bitvector.h | |
parent | 95f5be640fd362098a54e222d56d49144fe0efbe (diff) |
BitVector: Change setBit to set the bit in place. (#6176)
Creating BitVectors (and deleting them) is in general expensive because
of the underlying multi-precision Integer. If possible, unnecessary
constructions and desctructions of BitVectors should be avoided.
The most common use case for `setBit` is that for an existing BitVector,
a given bit should be set to a certain value. Not doing this in place
generates unnecessary constructions and destructions of BitVectors.
Diffstat (limited to 'src/util/bitvector.h')
-rw-r--r-- | src/util/bitvector.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/util/bitvector.h b/src/util/bitvector.h index ab6d8b030..c5a690c03 100644 --- a/src/util/bitvector.h +++ b/src/util/bitvector.h @@ -118,11 +118,13 @@ class BitVector /** * Set bit at index 'i' to given value. + * Returns a reference to this bit-vector to allow for chaining. + * * value: True to set bit to 1, and false to set it to 0. * * Note: Least significant bit is at index 0. */ - BitVector setBit(uint32_t i, bool value) const; + BitVector& setBit(uint32_t i, bool value); /** Return true if bit at index 'i' is 1, and false otherwise. */ bool isBitSet(uint32_t i) const; |