From 645ac3c239ea187d1b0b7266ba89a7bab3d3ada4 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Thu, 28 Jul 2022 14:12:57 -0700 Subject: [PATCH] optimized IncomingMessageDispatcher::HandleMessage a bit (flutter/engine#34954) * optimized IncomingMessageDispatcher::HandleMessage a bit. * removed std::string ref --- .../shell/platform/common/incoming_message_dispatcher.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/shell/platform/common/incoming_message_dispatcher.cc b/engine/src/flutter/shell/platform/common/incoming_message_dispatcher.cc index 07dd0b1900..5cc23d2481 100644 --- a/engine/src/flutter/shell/platform/common/incoming_message_dispatcher.cc +++ b/engine/src/flutter/shell/platform/common/incoming_message_dispatcher.cc @@ -19,14 +19,15 @@ void IncomingMessageDispatcher::HandleMessage( const std::function& input_unblock_cb) { std::string channel(message.channel); + auto callback_iterator = callbacks_.find(channel); // Find the handler for the channel; if there isn't one, report the failure. - if (callbacks_.find(channel) == callbacks_.end()) { + if (callback_iterator == callbacks_.end()) { FlutterDesktopMessengerSendResponse(messenger_, message.response_handle, nullptr, 0); return; } - auto& callback_info = callbacks_[channel]; - FlutterDesktopMessageCallback message_callback = callback_info.first; + auto& callback_info = callback_iterator->second; + const FlutterDesktopMessageCallback& message_callback = callback_info.first; // Process the call, handling input blocking if requested. bool block_input = input_blocking_channels_.count(channel) > 0;