LucaCappelletti94 commented on code in PR #2352:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2352#discussion_r3310496347


##########
src/parser/mod.rs:
##########
@@ -1801,7 +1832,21 @@ impl<'a> Parser<'a> {
                 // We first try to parse the word and following tokens as a 
special expression, and if that fails,
                 // we rollback and try to parse it as an identifier.
                 let w = w.clone();
-                match self.try_parse(|parser| 
parser.parse_expr_prefix_by_reserved_word(&w, span)) {
+                // Memoize failed speculative reserved-word parses. When
+                // the reserved arm (CASE, CURRENT_TIME, etc.) does
+                // exponential work but the unreserved fallback ultimately
+                // succeeds, the overall `parse_prefix` returns `Ok` and the
+                // outer cache never fires. Chains like `case-case-...c`
+                // need this per-arm cache to break the doubling.

Review Comment:
   Outer cache is the cache in the parent call before the recursive call, and 
doubling is that at each layer of depth it went in before, the operations 
doubled (hence the previous 2^layers complexity from before)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to