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

.

parent 8144a7e4
...@@ -89,9 +89,8 @@ func (A *RangedKeySet) UnionInplace(B *RangedKeySet) { ...@@ -89,9 +89,8 @@ func (A *RangedKeySet) UnionInplace(B *RangedKeySet) {
defer A.verify() defer A.verify()
// XXX dumb // XXX dumb
//for _, r := range B.rangev { for _, e := range B.m.entryv {
for _, r := range B.AllRanges() { A.AddRange(e.KeyRange)
A.AddRange(r)
} }
} }
...@@ -101,12 +100,11 @@ func (A *RangedKeySet) DifferenceInplace(B *RangedKeySet) { ...@@ -101,12 +100,11 @@ func (A *RangedKeySet) DifferenceInplace(B *RangedKeySet) {
defer A.verify() defer A.verify()
// XXX dumb // XXX dumb
// for _, r := range B.rangev { for _, e := range B.m.entryv {
for _, r := range B.AllRanges() {
if A.Empty() { if A.Empty() {
break break
} }
A.DelRange(r) A.DelRange(e.KeyRange)
} }
} }
...@@ -142,7 +140,14 @@ func (S *RangedKeySet) Clear() { ...@@ -142,7 +140,14 @@ func (S *RangedKeySet) Clear() {
// //
// TODO -> iter? // TODO -> iter?
func (S *RangedKeySet) AllRanges() /*readonly*/[]KeyRange { 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 // String
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
) )
func TestRangedKeySetTypes(t *testing.T) { func TestRangedKeySetTypes(t *testing.T) {
// verify that size(void) == 0 and that _RangedMap_voidEntry has the same layout as KeyRange
sizeVoid := unsafe.Sizeof(void{}) sizeVoid := unsafe.Sizeof(void{})
if sizeVoid != 0 { if sizeVoid != 0 {
t.Errorf("sizeof(void) = %d ; want 0", sizeVoid) 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