increasing string capacity to reduce allocations

This commit is contained in:
pedrocarlo 2025-02-04 15:38:02 -03:00
parent 90ecaf40b5
commit b678375c69

View file

@ -685,7 +685,7 @@ pub fn json_quote(value: &OwnedValue) -> crate::Result<OwnedValue> {
return Ok(value.to_owned());
}
let mut escaped_value = String::with_capacity(t.value.len());
let mut escaped_value = String::with_capacity(t.value.len() + 4);
escaped_value.push('"');
for c in t.value.to_string_lossy().chars() {
match c {