Skip to content

Commit

Permalink
Removing clone of Regex in regexp_replace
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Dec 23, 2023
1 parent 467905b commit adde667
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions datafusion/physical-expr/src/regex_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ pub fn regexp_replace<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef>

// if patterns hashmap already has regexp then use else else create and return
let re = match patterns.get(pattern) {
Some(re) => Ok(re.clone()),
Some(re) => Ok(re),
None => {
match Regex::new(pattern) {
Ok(re) => {
patterns.insert(pattern.to_string(), re.clone());
Ok(re)
patterns.insert(pattern.to_string(), re);
Ok(patterns.get(pattern).unwrap())
},
Err(err) => Err(DataFusionError::External(Box::new(err))),
}
Expand Down Expand Up @@ -240,12 +240,12 @@ pub fn regexp_replace<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef>

// if patterns hashmap already has regexp then use else else create and return
let re = match patterns.get(&pattern) {
Some(re) => Ok(re.clone()),
Some(re) => Ok(re),
None => {
match Regex::new(pattern.as_str()) {
Ok(re) => {
patterns.insert(pattern, re.clone());
Ok(re)
patterns.insert(pattern.clone(), re);
Ok(patterns.get(&pattern).unwrap())
},
Err(err) => Err(DataFusionError::External(Box::new(err))),
}
Expand Down

0 comments on commit adde667

Please sign in to comment.