Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7c6032d

Browse files
authored
Conform to clang_tidy in client_wrapper headers. (#46058)
Partial work towards flutter/flutter#134969. All of these were auto-suggested by Clang, and mostly avoid unnecessary copies.
1 parent 6fc076b commit 7c6032d

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <iostream>
99
#include <string>
10+
#include <utility>
1011

1112
#include "binary_messenger.h"
1213
#include "message_codec.h"
@@ -58,7 +59,8 @@ class BasicMessageChannel {
5859
void Send(const T& message, BinaryReply reply) {
5960
std::unique_ptr<std::vector<uint8_t>> raw_message =
6061
codec_->EncodeMessage(message);
61-
messenger_->Send(name_, raw_message->data(), raw_message->size(), reply);
62+
messenger_->Send(name_, raw_message->data(), raw_message->size(),
63+
std::move(reply));
6264
}
6365

6466
// Registers a handler that should be called any time a message is
@@ -77,7 +79,7 @@ class BasicMessageChannel {
7779
BinaryMessageHandler binary_handler = [handler, codec, channel_name](
7880
const uint8_t* binary_message,
7981
const size_t binary_message_size,
80-
BinaryReply binary_reply) {
82+
const BinaryReply& binary_reply) {
8183
// Use this channel's codec to decode the message and build a reply
8284
// handler.
8385
std::unique_ptr<T> message =

shell/platform/common/client_wrapper/include/flutter/event_channel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class EventChannel {
6969
// Mutable state to track the handler's listening status.
7070
is_listening = bool(false)](const uint8_t* message,
7171
const size_t message_size,
72-
BinaryReply reply) mutable {
72+
const BinaryReply& reply) mutable {
7373
constexpr char kOnListenMethod[] = "listen";
7474
constexpr char kOnCancelMethod[] = "cancel";
7575

shell/platform/common/client_wrapper/include/flutter/event_stream_handler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ struct StreamHandlerError {
2020
const std::string error_message;
2121
const std::unique_ptr<T> error_details;
2222

23-
StreamHandlerError(const std::string error_code,
24-
const std::string error_message,
23+
StreamHandlerError(const std::string& error_code,
24+
const std::string& error_message,
2525
std::unique_ptr<T>&& error_details)
2626
: error_code(error_code),
2727
error_message(error_message),

shell/platform/common/client_wrapper/include/flutter/method_result_functions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <functional>
99
#include <string>
10+
#include <utility>
1011

1112
#include "method_result.h"
1213

@@ -36,7 +37,7 @@ class MethodResultFunctions : public MethodResult<T> {
3637
ResultHandlerNotImplemented<T> on_not_implemented)
3738
: on_success_(on_success),
3839
on_error_(on_error),
39-
on_not_implemented_(on_not_implemented) {}
40+
on_not_implemented_(std::move(on_not_implemented)) {}
4041

4142
virtual ~MethodResultFunctions() = default;
4243

shell/platform/common/client_wrapper/include/flutter/texture_registrar.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <cstdint>
1111
#include <functional>
1212
#include <memory>
13+
#include <utility>
1314
#include <variant>
1415

1516
namespace flutter {
@@ -28,7 +29,7 @@ class PixelBufferTexture {
2829
// take care of proper synchronization. It also needs to be ensured that the
2930
// returned buffer isn't released prior to unregistering this texture.
3031
explicit PixelBufferTexture(CopyBufferCallback copy_buffer_callback)
31-
: copy_buffer_callback_(copy_buffer_callback) {}
32+
: copy_buffer_callback_(std::move(copy_buffer_callback)) {}
3233

3334
// Returns the callback-provided FlutterDesktopPixelBuffer that contains the
3435
// actual pixel data. The intended surface size is specified by |width| and

shell/platform/common/client_wrapper/testing/test_codec_extensions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Point {
3232
// variable-length type that includes types handled by the core standard codec.
3333
class SomeData {
3434
public:
35-
SomeData(const std::string label, const std::vector<uint8_t>& data)
35+
SomeData(const std::string& label, const std::vector<uint8_t>& data)
3636
: label_(label), data_(data) {}
3737
~SomeData() = default;
3838

0 commit comments

Comments
 (0)