Refactor MQTT::onReceive to reduce if/else nesting (#5592)

* Refactor MQTT::onReceive to reduce if/else nesting

* Fix missing #include <functional>

* const DecodedServiceEnvelope e

* Combine validDecode if statement.

* Only call pb_release when validDecode.

* s/ptr/channelName/

* Use reference type for deleter

* Use lambda instead of bind

* Document deleter

* Reorder 'if's to avoid object creation

* Remove unnecessary comment

* Remove 'else'; simpifies #5516

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Eric Severance
2024-12-19 03:47:46 -08:00
committed by GitHub
parent 68413486e3
commit 8c6eec52f2
4 changed files with 213 additions and 179 deletions

View File

@@ -44,6 +44,7 @@ typedef int ErrorCode;
/// Alloc and free packets to our global, ISR safe pool
extern Allocator<meshtastic_MeshPacket> &packetPool;
using UniquePacketPoolPacket = Allocator<meshtastic_MeshPacket>::UniqueAllocation;
/**
* Most (but not always) of the time we want to treat packets 'from' the local phone (where from == 0), as if they originated on