Dimchikkk commented on code in PR #13414: URL: https://github.com/apache/datafusion/pull/13414#discussion_r1842755078
########## datafusion/functions/src/regex/regexpcount.rs: ########## @@ -548,19 +549,25 @@ where } } -fn compile_and_cache_regex<'a>( - regex: &'a str, - flags: Option<&'a str>, - regex_cache: &'a mut HashMap<String, Regex>, -) -> Result<&'a Regex, ArrowError> { - if !regex_cache.contains_key(regex) { +fn compile_and_cache_regex<'strings, 'cache>( + regex: &'strings str, + flags: Option<&'strings str>, + regex_cache: &'cache mut HashMap<(&'strings str, Option<&'strings str>), Regex>, +) -> Result<&'cache Regex, ArrowError> +where + 'strings: 'cache, Review Comment: "strings outlives hashmap" or "strings lasts longer than hashmap", so hashmap can borrow data from strings (because while hashmap holds data from strings, strings won't die), but if hashmap dies before strings dies, it's fine. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org