You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tustvold (via GitHub)" <gi...@apache.org> on 2023/12/22 21:03:12 UTC
Re: [PR] Improve regexp kernels performance by avoiding cloning Regex [arrow-rs]
tustvold commented on code in PR #5235:
URL: https://github.com/apache/arrow-rs/pull/5235#discussion_r1435345943
##########
arrow-string/src/regexp.rs:
##########
@@ -81,15 +81,15 @@ pub fn regexp_is_match_utf8<OffsetSize: OffsetSizeTrait>(
(Some(value), Some(pattern)) => {
let existing_pattern = patterns.get(&pattern);
let re = match existing_pattern {
- Some(re) => re.clone(),
+ Some(re) => re,
None => {
let re = Regex::new(pattern.as_str()).map_err(|e| {
ArrowError::ComputeError(format!(
"Regular expression did not compile: {e:?}"
))
})?;
- patterns.insert(pattern, re.clone());
- re
+ patterns.insert(pattern.clone(), re);
Review Comment:
Perhaps you could use https://doc.rust-lang.org/std/collections/hash_map/enum.Entry.html#method.or_insert
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org