Description
PInterval
as it is provided by the ledger api is very inefficient for complicated operations on interval. pcontains
as it is is well optimized and having intermediary representation will actually do harm on its performance by introducing extra conversion from ledger type to intermediary type. However, if script requires multiple and more complicated operations(like a series of checking interval union, intersection, etc, etc) on interval, it would be cheaper to convert ledger interval into intermediary interval, do multiple operation on converted interval, and convert back to ledger interval.
Below is possible idea for more efficient intermediary interval proposed by @kozross.
data PClosured (a :: S -> Type) (s :: S) = POpen (Term s a) | PClosed (Term s a)
data PIntervalSensible (a :: S -> Type) (s :: S) =
= PNever
| PAlways
| PStartNoEnd (Term s (PClosure a))
| PEndNoStart (Term s (PClosure a))
| PIntervalSensible (Term s (PClosure a)) (Term s (PClosure a))
Because this optimization is very specifically targeted to scripts that require complicated interval operations, this issue will only be implemented upon request if any project need this.