From 8809918e4e82521f9d3a35763b26ed830147a3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lucas?= Date: Thu, 11 Jun 2026 09:24:19 -0300 Subject: [PATCH] perf(wacore): drop the proto PartialEq anchor from the skdm-only check The slow path compared the stripped message against Message::default(), which was the only production caller of prost's derived PartialEq and kept the eq impls for the entire message tree alive in every binary (94 KiB across 148 functions). Under proto2 presence rules a field only contributes encoded bytes when set, so encoded_len == 0 is the same predicate; it reuses the codec tree already pinned by waproto::codec. Measured on the release bin: .text 11.65 MiB to 11.55 MiB (-102 KiB), proto eq impls 148 to 0. Applies to stable and nightly builds alike. --- wacore/src/messages.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wacore/src/messages.rs b/wacore/src/messages.rs index b67856d39..bc928b948 100644 --- a/wacore/src/messages.rs +++ b/wacore/src/messages.rs @@ -422,7 +422,9 @@ pub fn is_sender_key_distribution_only(msg: &mut wa::Message) -> bool { let fast = msg.fast_ratchet_key_sender_key_distribution_message.take(); let ctx = msg.message_context_info.take(); - let only = *msg == wa::Message::default(); + // Same predicate as `== Message::default()` (proto2 fields only encode + // when set), without anchoring prost's derived PartialEq tree. + let only = waproto::codec::message_encoded_len(msg) == 0; msg.sender_key_distribution_message = skdm; msg.fast_ratchet_key_sender_key_distribution_message = fast;