From d7a1cae6a363a357202523089b8873181063809c Mon Sep 17 00:00:00 2001 From: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:19:13 -0500 Subject: [PATCH] Add note on possible future filtering optimization. (#699) --- trustfall_core/src/interpreter/filtering.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/trustfall_core/src/interpreter/filtering.rs b/trustfall_core/src/interpreter/filtering.rs index 02afb22a..77416afa 100644 --- a/trustfall_core/src/interpreter/filtering.rs +++ b/trustfall_core/src/interpreter/filtering.rs @@ -391,6 +391,12 @@ fn apply_filter_op< left: &FieldValue, right: &RightValue, ) -> Option> { + // TODO: This is a missed optimization opportunity: + // It's possible that computing the arguments for the filter function was expensive, + // and we might have been able to skip it if `ctx.within_nonexistent_optional()` is true. + // With the current impl, we fail to do so. + // For example: we may have created a Regex value from a tag, or used a `@transform` on + // a property to perform some computation on either the left or right value (#617). (ctx.within_nonexistent_optional() || filter_op(left, right)).then_some(ctx) }