Commit 4930c3a9 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8144a7e4
......@@ -89,9 +89,8 @@ func (A *RangedKeySet) UnionInplace(B *RangedKeySet) {
defer A.verify()
// XXX dumb
//for _, r := range B.rangev {
for _, r := range B.AllRanges() {
A.AddRange(r)
for _, e := range B.m.entryv {
A.AddRange(e.KeyRange)
}
}
......@@ -101,12 +100,11 @@ func (A *RangedKeySet) DifferenceInplace(B *RangedKeySet) {
defer A.verify()
// XXX dumb
// for _, r := range B.rangev {
for _, r := range B.AllRanges() {
for _, e := range B.m.entryv {
if A.Empty() {
break
}
A.DelRange(r)
A.DelRange(e.KeyRange)
}
}
......@@ -142,7 +140,14 @@ func (S *RangedKeySet) Clear() {
//
// TODO -> iter?
func (S *RangedKeySet) AllRanges() /*readonly*/[]KeyRange {
return []KeyRange(S.m.AllRanges())
// TODO we could use unsafe and cast .m.AllRanges to []KeyRange to avoid extra alloc/copy
// return []KeyRange(S.m.AllRanges())
ev := S.m.AllRanges()
rv := make([]KeyRange, len(ev))
for i := range ev {
rv[i] = ev[i].KeyRange
}
return rv
}
// String
......@@ -25,6 +25,7 @@ import (
)
func TestRangedKeySetTypes(t *testing.T) {
// verify that size(void) == 0 and that _RangedMap_voidEntry has the same layout as KeyRange
sizeVoid := unsafe.Sizeof(void{})
if sizeVoid != 0 {
t.Errorf("sizeof(void) = %d ; want 0", sizeVoid)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment