| 69 | } |
| 70 | |
| 71 | func (ra *roaringArray64) appendCopiesUntil(sa roaringArray64, stoppingKey uint32) { |
| 72 | // cow only if the two request it, or if we already have a lightweight copy |
| 73 | copyonwrite := ra.copyOnWrite && sa.copyOnWrite |
| 74 | |
| 75 | for i := 0; i < sa.size(); i++ { |
| 76 | if sa.keys[i] >= stoppingKey { |
| 77 | break |
| 78 | } |
| 79 | thiscopyonewrite := copyonwrite || sa.needsCopyOnWrite(i) |
| 80 | if thiscopyonewrite { |
| 81 | ra.appendContainer(sa.keys[i], sa.containers[i], thiscopyonewrite) |
| 82 | if !sa.needsCopyOnWrite(i) { |
| 83 | sa.setNeedsCopyOnWrite(i) |
| 84 | } |
| 85 | |
| 86 | } else { |
| 87 | // since there is no copy-on-write, we need to clone the container (this is important) |
| 88 | ra.appendContainer(sa.keys[i], sa.containers[i].Clone(), thiscopyonewrite) |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | func (ra *roaringArray64) appendCopiesAfter(sa roaringArray64, beforeStart uint32) { |
| 94 | // cow only if the two request it, or if we already have a lightweight copy |