mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-03 08:24:19 +01:00
Merge 'core/translate: sanize_string fast path improvement' from Pere Diaz Bou
Closes #2827
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user