From bf8f7b04c8caecc65b790be224d76c652bb7609a Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Thu, 14 Sep 2023 22:29:59 -0400 Subject: [PATCH] tiny fix --- src/expr/src/vector_op/regexp.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/expr/src/vector_op/regexp.rs b/src/expr/src/vector_op/regexp.rs index 32103ee24e0c1..1d83a895e1b0c 100644 --- a/src/expr/src/vector_op/regexp.rs +++ b/src/expr/src/vector_op/regexp.rs @@ -33,15 +33,10 @@ impl RegexpContext { fn new(pattern: &str, flags: &str, replacement: &str) -> Result { let options = RegexpOptions::from_str(flags)?; - // FIXME: Any better solution? - let mut origin = String::with_capacity(pattern.len()); - - if options.case_insensitive { - origin.push_str("(?i:"); - origin.push_str(pattern); - origin.push(')'); + let origin = if options.case_insensitive { + format!("(?i:{})", pattern) } else { - origin = pattern.to_string(); + pattern.to_string() }; Ok(Self {