mirror of
https://github.com/flectar/mail.git
synced 2026-11-13 18:44:12 +00:00
perf: reserve escaped calendar values precisely
This commit is contained in:
1 parent
bb79e29575
commit
fbbbccf61c
1 file changed
+9
-1
@@ -515,7 +515,15 @@ pub fn parse_ics(text: &str) -> Vec<IcsEvent> {
|
||||
}
|
||||
|
||||
pub(crate) fn escape(v: &str) -> String {
|
||||
let mut out = String::with_capacity(v.len());
|
||||
let capacity = v
|
||||
.chars()
|
||||
.map(|character| match character {
|
||||
'\\' | ',' | ';' | '\n' => 2,
|
||||
'\r' => 0,
|
||||
_ => character.len_utf8(),
|
||||
})
|
||||
.sum();
|
||||
let mut out = String::with_capacity(capacity);
|
||||
for c in v.chars() {
|
||||
match c {
|
||||
'\\' => out.push_str("\\\\"),
|
||||
|
||||
Reference in new issue
Block a user