diff --git a/core/translate/expr.rs b/core/translate/expr.rs index 398b31c3c..bae89f612 100644 --- a/core/translate/expr.rs +++ b/core/translate/expr.rs @@ -2619,7 +2619,14 @@ pub fn maybe_apply_affinity(col_type: Type, target_register: usize, program: &mu /// Sanitizes a string literal by removing single quote at front and back /// and escaping double single quotes pub fn sanitize_string(input: &str) -> String { - input[1..input.len() - 1].replace("''", "'").to_string() + let inner = &input[1..input.len() - 1]; + + // Fast path, avoid replacing. + if !inner.contains("''") { + return inner.to_string(); + } + + inner.replace("''", "'") } /// Sanitizes a double-quoted string literal by removing double quotes at front and back