From 274da5d7bc049c748b0eb04f24275efe15ab7720 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Wed, 2 Mar 2022 22:31:12 +0100 Subject: Stanza: Make E2eeMetadata optional to avoid allocation Avoids an allocation of the E2eeMetadataPrivate object when it's not used. It doesn't use optional directly because that wouldn't avoid the allocation and takes up 16 bytes instead of 8. This concept could be generalized and used elsewhere in the code (e.g. extended addresses in the stanza are unused 99% of the time). --- src/client/QXmppAtmManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/client/QXmppAtmManager.cpp') diff --git a/src/client/QXmppAtmManager.cpp b/src/client/QXmppAtmManager.cpp index 957ed8ef..2c9a8568 100644 --- a/src/client/QXmppAtmManager.cpp +++ b/src/client/QXmppAtmManager.cpp @@ -297,7 +297,8 @@ QFuture QXmppAtmManager::handleMessage(const QXmppMessage &message) trustMessageElement->usage() == ns_atm && message.from() != client()->configuration().jid()) { const auto senderJid = QXmppUtils::jidToBareJid(message.from()); - const auto senderKey = message.e2eeMetadata().senderKey(); + const auto e2eeMetadata = message.e2eeMetadata(); + const auto senderKey = e2eeMetadata ? e2eeMetadata->senderKey() : QByteArray(); const auto encryption = trustMessageElement->encryption(); auto future = m_trustStorage->trustLevel(encryption, senderKey); -- cgit v1.2.3