mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Have lib/interval's split2Ways return emptiness
This commit is contained in:
1 parent
648932e0fb
commit
960a3b76d7
1 file changed
+9
-17
@@ -312,15 +312,15 @@ func (x IntRange) justZero() bool {
|
|||||||
// split2Ways splits x into negative and non-negative sub-intervals. The
|
// split2Ways splits x into negative and non-negative sub-intervals. The
|
||||||
// IntRange values returned may be empty, which means that x does not contain
|
// IntRange values returned may be empty, which means that x does not contain
|
||||||
// any negative or non-negative elements.
|
// any negative or non-negative elements.
|
||||||
func (x IntRange) split2Ways() (neg IntRange, nonNeg IntRange) {
|
func (x IntRange) split2Ways() (neg IntRange, nonNeg IntRange, hasNeg bool, hasPos bool) {
|
||||||
if x.Empty() {
|
if x.Empty() {
|
||||||
return sharedEmptyRange, sharedEmptyRange
|
return sharedEmptyRange, sharedEmptyRange, false, false
|
||||||
}
|
}
|
||||||
if x[0] != nil && x[0].Sign() >= 0 {
|
if x[0] != nil && x[0].Sign() >= 0 {
|
||||||
return sharedEmptyRange, x
|
return sharedEmptyRange, x, false, true
|
||||||
}
|
}
|
||||||
if x[1] != nil && x[1].Sign() < 0 {
|
if x[1] != nil && x[1].Sign() < 0 {
|
||||||
return x, sharedEmptyRange
|
return x, sharedEmptyRange, true, false
|
||||||
}
|
}
|
||||||
|
|
||||||
neg[0] = x[0]
|
neg[0] = x[0]
|
||||||
@@ -335,7 +335,7 @@ func (x IntRange) split2Ways() (neg IntRange, nonNeg IntRange) {
|
|||||||
}
|
}
|
||||||
nonNeg[1] = x[1]
|
nonNeg[1] = x[1]
|
||||||
|
|
||||||
return neg, nonNeg
|
return neg, nonNeg, true, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// split splits x into negative, zero and positive sub-intervals. The IntRange
|
// split splits x into negative, zero and positive sub-intervals. The IntRange
|
||||||
@@ -746,12 +746,8 @@ func (x IntRange) And(y IntRange) (z IntRange, ok bool) {
|
|||||||
return andBothNonNeg(x, y), true
|
return andBothNonNeg(x, y), true
|
||||||
}
|
}
|
||||||
|
|
||||||
xNeg, xNon := x.split2Ways()
|
xNeg, xNon, hasXNeg, hasXNon := x.split2Ways()
|
||||||
yNeg, yNon := y.split2Ways()
|
yNeg, yNon, hasYNeg, hasYNon := y.split2Ways()
|
||||||
hasXNeg := !xNeg.Empty()
|
|
||||||
hasXNon := !xNon.Empty()
|
|
||||||
hasYNeg := !yNeg.Empty()
|
|
||||||
hasYNon := !yNon.Empty()
|
|
||||||
|
|
||||||
z = makeEmptyRange()
|
z = makeEmptyRange()
|
||||||
if hasXNeg {
|
if hasXNeg {
|
||||||
@@ -855,12 +851,8 @@ func (x IntRange) Or(y IntRange) (z IntRange, ok bool) {
|
|||||||
return orBothNonNeg(x, y), true
|
return orBothNonNeg(x, y), true
|
||||||
}
|
}
|
||||||
|
|
||||||
xNeg, xNon := x.split2Ways()
|
xNeg, xNon, hasXNeg, hasXNon := x.split2Ways()
|
||||||
yNeg, yNon := y.split2Ways()
|
yNeg, yNon, hasYNeg, hasYNon := y.split2Ways()
|
||||||
hasXNeg := !xNeg.Empty()
|
|
||||||
hasXNon := !xNon.Empty()
|
|
||||||
hasYNeg := !yNeg.Empty()
|
|
||||||
hasYNon := !yNon.Empty()
|
|
||||||
|
|
||||||
z = makeEmptyRange()
|
z = makeEmptyRange()
|
||||||
if hasXNeg {
|
if hasXNeg {
|
||||||
|
|||||||
Reference in new issue
Block a user