Skip to content

Commit 0f8e2cc

Browse files
committed
wip
1 parent e88a9ae commit 0f8e2cc

File tree

2 files changed

+111
-227
lines changed

2 files changed

+111
-227
lines changed

or.go

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,12 @@ func Compact(o Or) Constrainter { // TODO: Test me.
4949
ceiling, ceilingOk := maxFloorlessCeiling(o...)
5050
floor, floorOk := minCeilinglessFloor(o...)
5151

52-
if ceilingOk && floorOk {
53-
if matchAll(ceiling.ceiling(), floor.floor()) {
54-
return NewWildcard()
55-
}
56-
}
57-
5852
o = slices.DeleteFunc(o, func(c CeilingFloorConstrainter) bool {
5953
return c.ceiling().wildcard() || c.floor().wildcard()
6054
})
6155

56+
// TODO: Find ceiling.
57+
6258
if floorOk {
6359
for i := range o {
6460
if o[i].Check(*floor.version) {
@@ -81,35 +77,19 @@ func Compact(o Or) Constrainter { // TODO: Test me.
8177
}
8278
continue
8379
}
84-
85-
//if floor.Check(*o[i].ceiling().version) {
86-
// floor = o[i].floor()
87-
// continue
88-
//}
89-
90-
//if floor.Check(*o[i].ceiling().version) {
91-
// continue
92-
//}
93-
//
94-
//if floor.compare(o[i].floor()) < 0 {
95-
// continue
96-
//}
97-
//
98-
//if floor.compare(o[i].floor()) > 0 {
99-
// //floor = o[i].floor()
100-
// continue
101-
//}
102-
//
103-
//if o[i].floor().inclusive() {
104-
// floor = o[i].floor()
105-
//}
10680
}
10781

10882
o = slices.DeleteFunc(o, func(c CeilingFloorConstrainter) bool {
10983
return floor.compare(c.floor()) <= 0
11084
})
11185
}
11286

87+
if ceilingOk && floorOk {
88+
if matchAll(ceiling, floor) {
89+
return NewWildcard()
90+
}
91+
}
92+
11393
// important to sort before compacting
11494
slices.SortFunc(o, compare)
11595
// remove duplicates
@@ -143,6 +123,10 @@ func Compact(o Or) Constrainter { // TODO: Test me.
143123
vals = append(vals, ceiling)
144124
}
145125

126+
if len(vals) == 1 {
127+
return vals[0]
128+
}
129+
146130
slices.SortFunc(vals, compare)
147131
return slices.Clip(vals)
148132
}

0 commit comments

Comments
 (0)