diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-02-19 10:24:50 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-02-19 10:24:50 -0800 |
commit | d93fc01d58f4b2f20cd4d631d1a72fcd0e1aa438 (patch) | |
tree | 6077001dca401dda2aa76493e87432ba7ad522d1 /src | |
parent | 812790a2dc4f961bbc8706a9e8a63887172057df (diff) | |
parent | c9930bfaf28093fe419de3cf034b4bf7888b3818 (diff) | |
download | scala-d93fc01d58f4b2f20cd4d631d1a72fcd0e1aa438.tar.gz scala-d93fc01d58f4b2f20cd4d631d1a72fcd0e1aa438.tar.bz2 scala-d93fc01d58f4b2f20cd4d631d1a72fcd0e1aa438.zip |
Merge pull request #4330 from Ichoran/issue/8917
SI-8917 collection.mutable.BitSet's &= operator doesn't clear end
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/mutable/BitSet.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/library/scala/collection/mutable/BitSet.scala b/src/library/scala/collection/mutable/BitSet.scala index 78150b5e88..e92d48cfeb 100644 --- a/src/library/scala/collection/mutable/BitSet.scala +++ b/src/library/scala/collection/mutable/BitSet.scala @@ -121,8 +121,10 @@ class BitSet(protected final var elems: Array[Long]) extends AbstractSet[Int] * @return the bitset itself. */ def &= (other: BitSet): this.type = { - ensureCapacity(other.nwords - 1) - for (i <- 0 until other.nwords) + // Different from other operations: no need to ensure capacity because + // anything beyond the capacity is 0. Since we use other.word which is 0 + // off the end, we also don't need to make sure we stay in bounds there. + for (i <- 0 until nwords) elems(i) = elems(i) & other.word(i) this } |