File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed
Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -137,20 +137,10 @@ function union!(s::BitSet, r::AbstractUnitRange{<:Integer})
137137
138138 # grow s.bits as necessary
139139 if diffb >= len
140- _growend! (s. bits, diffb - len + 1 )
141- # we set only some values to CHK0, those which will not be
142- # fully overwritten (i.e. only or'ed with `|`)
143- s. bits[end ] = CHK0 # end == diffb + 1
144- if diffa >= len
145- s. bits[diffa + 1 ] = CHK0
146- end
140+ _growend0! (s. bits, diffb - len + 1 )
147141 end
148142 if diffa < 0
149- _growbeg! (s. bits, - diffa)
150- s. bits[1 ] = CHK0
151- if diffb < 0
152- s. bits[diffb - diffa + 1 ] = CHK0
153- end
143+ _growbeg0! (s. bits, - diffa)
154144 s. offset = cidxa # s.offset += diffa
155145 diffb -= diffa
156146 diffa = 0
Original file line number Diff line number Diff line change 351351 # union! with an empty range doesn't modify the BitSet
352352 @test union! (x, b: a) == y
353353end
354+
355+ @testset " union!(::BitSet, ::AbstractUnitRange) when two ranges do not overlap" begin
356+ # see #45574
357+ a, b = rand (- 10000 : - 5000 ), rand (5000 : 10000 )
358+ c, d = minmax (rand (20000 : 30000 , 2 )... )
359+ @test length (union! (BitSet (a: b), c: d)) == length (a: b) + length (c: d)
360+ c, d = minmax (rand (- 30000 : - 20000 , 2 )... )
361+ @test length (union! (BitSet (a: b), c: d)) == length (a: b) + length (c: d)
362+ end
You can’t perform that action at this time.
0 commit comments