MCPcopy
hub / github.com/RoaringBitmap/roaring / appendCopiesUntil

Method appendCopiesUntil

roaringarray.go:182–202  ·  view source on GitHub ↗
(sa roaringArray, stoppingKey uint16)

Source from the content-addressed store, hash-verified

180}
181
182func (ra *roaringArray) appendCopiesUntil(sa roaringArray, stoppingKey uint16) {
183 // cow only if the two request it, or if we already have a lightweight copy
184 copyonwrite := ra.copyOnWrite && sa.copyOnWrite
185
186 for i := 0; i < sa.size(); i++ {
187 if sa.keys[i] >= stoppingKey {
188 break
189 }
190 thiscopyonewrite := copyonwrite || sa.needsCopyOnWrite(i)
191 if thiscopyonewrite {
192 ra.appendContainer(sa.keys[i], sa.containers[i], thiscopyonewrite)
193 if !sa.needsCopyOnWrite(i) {
194 sa.setNeedsCopyOnWrite(i)
195 }
196
197 } else {
198 // since there is no copy-on-write, we need to clone the container (this is important)
199 ra.appendContainer(sa.keys[i], sa.containers[i].clone(), thiscopyonewrite)
200 }
201 }
202}
203
204func (ra *roaringArray) appendCopiesAfter(sa roaringArray, beforeStart uint16) {
205 // cow only if the two request it, or if we already have a lightweight copy

Callers 1

FlipFunction · 0.45

Calls 5

appendContainerMethod · 0.95
cloneMethod · 0.65
sizeMethod · 0.45
needsCopyOnWriteMethod · 0.45
setNeedsCopyOnWriteMethod · 0.45

Tested by

no test coverage detected