getUnionedWritableContainer switches behavior for in-place Or depending on whether the container requires a copy on write. If it does using the non-inplace or() method leads to fewer allocations.
(pos int, other container)
| 339 | // depending on whether the container requires a copy on write. |
| 340 | // If it does using the non-inplace or() method leads to fewer allocations. |
| 341 | func (ra *roaringArray) getUnionedWritableContainer(pos int, other container) container { |
| 342 | if ra.needCopyOnWrite[pos] { |
| 343 | return ra.getContainerAtIndex(pos).or(other) |
| 344 | } |
| 345 | return ra.getContainerAtIndex(pos).ior(other) |
| 346 | } |
| 347 | |
| 348 | func (ra *roaringArray) getWritableContainerAtIndex(i int) container { |
| 349 | if ra.needCopyOnWrite[i] { |
no test coverage detected