jayzhan211 commented on code in PR #13364: URL: https://github.com/apache/datafusion/pull/13364#discussion_r1837355468
########## datafusion/functions/src/regex/regexpcount.rs: ########## @@ -541,42 +541,45 @@ where let pattern = compile_and_cache_regex(regex, flags, &mut regex_cache)?; - count_matches(value, &pattern, start) + count_matches(value, pattern, start) }) .collect::<Result<Vec<i64>, ArrowError>>()?, ))) } } } -fn compile_and_cache_regex( - regex: &str, - flags: Option<&str>, - regex_cache: &mut HashMap<String, Regex>, -) -> Result<Regex, ArrowError> { - match regex_cache.entry(regex.to_string()) { - Entry::Vacant(entry) => { - let compiled = compile_regex(regex, flags)?; - entry.insert(compiled.clone()); - Ok(compiled) - } - Entry::Occupied(entry) => Ok(entry.get().to_owned()), +fn compile_and_cache_regex<'a>( + regex: &'a str, + flags: Option<&'a str>, + regex_cache: &'a mut HashMap<String, Regex>, Review Comment: Is `HashMap<&str, Regex>` much better for avoiding clone? -- 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