runOptimize compresses the element containers to minimize space consumed. Q: how does this interact with copyOnWrite and needCopyOnWrite? A: since we aren't changing the logical content, just the representation, we don't bother to check the needCopyOnWrite bits. We replace (possibly all) elements
()
| 137 | // (possibly all) elements of ra.containers in-place with space |
| 138 | // optimized versions. |
| 139 | func (ra *roaringArray) runOptimize() { |
| 140 | for i := range ra.containers { |
| 141 | ra.containers[i] = ra.containers[i].toEfficientContainer() |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | func (ra *roaringArray) appendContainer(key uint16, value container, mustCopyOnWrite bool) { |
| 146 | ra.keys = append(ra.keys, key) |