perf(caldav): zero-alloc iCal generation with write!()

Replace push_str(&format!(...)) pattern in generate_full_calendar_ical,
generate_event_ical, and generate_vevent with direct write!() into a
pre-sized String buffer.

Before: ~5N+1 heap allocations for N events (temporary Strings created
by format!(), copied into the main buffer, then dropped).

After: 1 allocation (the initial String::with_capacity). All write!()
calls format directly into the destination buffer with zero intermediate
Strings.
This commit is contained in:
Dionisio
2026-03-02 23:58:15 +01:00
parent 2c3dde2d75
commit 7b2a8577a9
3 changed files with 258 additions and 84 deletions
+8 -8
View File
@@ -12,30 +12,30 @@ tokio = { version = "1.49.0", features = ["rt-multi-thread", "macros", "io-util"
tokio-util = { version = "0.7.18", features = ["io", "codec", "compat"] }
tokio-stream = { version = "0.1.18", features = ["fs"] }
bytes = "1.11.1"
tempfile = "3.25.0"
tempfile = "3.26.0"
tower = "0.5.3"
tower-http = { version = "0.6.8", features = ["fs", "compression-gzip", "compression-br", "trace", "cors", "add-extension", "request-id", "set-header", "limit"] }
flate2 = "1.1.9"
tracing = "0.1.44"
tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }
chrono = { version = "0.4.43", features = ["serde"] }
chrono = { version = "0.4.44", features = ["serde"] }
http-body = "1.0.1"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149"
futures = "0.3.31"
futures = "0.3.32"
async-stream = "0.3.6"
mime_guess = "2.0.5"
uuid = { version = "1.20.0", features = ["v4", "serde"] }
uuid = { version = "1.21.0", features = ["v4", "serde"] }
async-trait = "0.1.89"
thiserror = "2.0.18"
mockall = { version = "0.14.0", optional = true }
sqlx = { version = "0.8.6", features = ["postgres", "runtime-tokio", "tls-rustls", "chrono", "uuid", "json"] }
anyhow = "1.0.101"
jsonwebtoken = { version = "10.1.0", features = ["rust_crypto"] }
anyhow = "1.0.102"
jsonwebtoken = { version = "10.3.0", features = ["rust_crypto"] }
argon2 = "0.5.3"
rand_core = { version = "0.6", features = ["std", "getrandom"] }
hyper = { version = "1.8.1", features = ["full"] }
quick-xml = "0.39.0"
quick-xml = "0.39.2"
dotenvy = "0.15.7"
moka = { version = "0.12", features = ["future", "sync"] }
http-range-header = "0.4"
@@ -49,7 +49,7 @@ percent-encoding = "2.3"
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls-webpki-roots"] }
base64 = "0.22.1"
fs2 = "0.4"
rayon = "1.10"
rayon = "1.11"
infer = "0.19"
async-compression = { version = "0.4", features = ["tokio", "gzip"] }
async_zip = { version = "0.0.18", features = ["tokio", "deflate"] }