Optimize is_number strategy
Filtering `term` with `Term::is_number` is too slow, on the order of
minutes instead of seconds because most terms aren't numbers, so
create a new strategy that is only the subset of `term` that produce
numbers.
@@ -61,9 +61,19 @@ pub fn is_not_number(arc_process: Arc<Process>) -> BoxedStrategy<Term> {
.boxed()
}
+// `super::term(arc_process).prop_filter(..., |v| v.is_number())` is too slow, on the order of
+// minutes instead of seconds because most terms aren't numbers, so this directly uses the
+// number strategies instead.
pub fn is_number(arc_process: Arc<Process>) -> BoxedStrategy<Term> {
- super::term(arc_process)
- .prop_filter("Value must be a number", |v| v.is_number())
+ let big_integer_arc_process = arc_process.clone();
+ let float_arc_process = arc_process.clone();
+ let small_integer_arc_process = arc_process.clone();
+
+ prop_oneof![
+ integer::big(big_integer_arc_process),
+ float(float_arc_process),
+ integer::small(small_integer_arc_process)
+ ]
.boxed()
}
