@@ -29,7 +29,7 @@ function makeKey(
2929 return `${ queryCausingWork } :${ predicate } ${ suffix ? ' ' + suffix : '' } ` ;
3030}
3131
32- function getDependentPredicates ( operations : string [ ] ) : I . List < string > {
32+ const DEPENDENT_PREDICATES_REGEXP = ( ( ) = > {
3333 const regexps = [
3434 // SCAN id
3535 String . raw `SCAN\s+([0-9a-zA-Z:#_]+)\s` ,
@@ -44,16 +44,23 @@ function getDependentPredicates(operations: string[]): I.List<string> {
4444 // SELECT id
4545 String . raw `SELECT\s+([0-9a-zA-Z:#_]+)`
4646 ] ;
47- const r = new RegExp (
47+ return new RegExp (
4848 `${ String . raw `\{[0-9]+\}\s+[0-9a-zA-Z]+\s=\s(?:` + regexps . join ( '|' ) } )`
4949 ) ;
50+ } ) ( ) ;
51+
52+ function getDependentPredicates ( operations : string [ ] ) : I . List < string > {
5053 return I . List ( operations ) . flatMap ( operation => {
51- const matches = r . exec ( operation . trim ( ) ) ;
52- return I . List ( matches ! )
53- . rest ( ) // Skip the first group as it's just the entire string
54- . filter ( x => ! x ?. match ( 'r[0-9]+|PRIMITIVE' ) ) // Only keep the references to predicates.
55- . flatMap ( x => x . split ( ',' ) ) // Group 2 in the INVOKE HIGHER_ORDER RELATION case is a comma-separated list of identifiers.
56- . filter ( x => ! ! x ) ; // Remove empty strings
54+ const matches = DEPENDENT_PREDICATES_REGEXP . exec ( operation . trim ( ) ) ;
55+ if ( matches !== null ) {
56+ return I . List ( matches )
57+ . rest ( ) // Skip the first group as it's just the entire string
58+ . filter ( x => ! ! x && ! x . match ( 'r[0-9]+|PRIMITIVE' ) ) // Only keep the references to predicates.
59+ . flatMap ( x => x . split ( ',' ) ) // Group 2 in the INVOKE HIGHER_ORDER RELATION case is a comma-separated list of identifiers.
60+ . filter ( x => ! ! x ) ; // Remove empty strings
61+ } else {
62+ return I . List ( ) ;
63+ }
5764 } ) ;
5865}
5966
0 commit comments