From 082f18c0735ccbe690d1f18d1ef0a6311ff58599 Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Thu, 28 Aug 2025 10:49:54 +0000 Subject: [PATCH] core/translate: sanize_string fast path improvement --- core/translate/expr.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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