Merge 'core/translate: sanize_string fast path improvement' from Pere Diaz Bou

Closes #2827
This commit is contained in:
Pekka Enberg
2025-08-28 14:32:43 +03:00
committed by GitHub

View File

@@ -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