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

Commit 34af9d1

Browse files
committed
Turned on performance-unnecessary-value-param everywhere.
1 parent c1200c4 commit 34af9d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+116
-94
lines changed

.clang-tidy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ clang-analyzer-*,\
2828
readability-identifier-naming,\
2929
clang-diagnostic-*,\
3030
google-objc-*,\
31-
google-explicit-constructor"
31+
google-explicit-constructor,\
32+
performance-unnecessary-value-param"
3233

3334
CheckOptions:
3435
- key: modernize-use-default-member-init.UseAssignment

ci/lint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ DART_BIN="${SRC_DIR}/third_party/dart/tools/sdks/dart-sdk/bin"
3434
DART="${DART_BIN}/dart"
3535
# TODO(https://github.com/flutter/flutter/issues/113848): Migrate all platforms
3636
# to have this as an error.
37-
MAC_HOST_WARNINGS_AS_ERRORS="performance-move-const-arg,performance-unnecessary-value-param"
37+
MAC_HOST_WARNINGS_AS_ERRORS="performance-move-const-arg"
3838

39+
FLUTTER_LINT_PRINT_FIX=1
3940
# FLUTTER_LINT_PRINT_FIX will make it so that fix is executed and the generated
4041
# diff is printed to stdout if clang-tidy fails. This is helpful for enabling
4142
# new lints.

fml/platform/android/jni_weak_ref.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ ScopedJavaLocalRef<jobject> GetRealObject(JNIEnv* env, jweak obj) {
5454
}
5555

5656
void JavaObjectWeakGlobalRef::Assign(const JavaObjectWeakGlobalRef& other) {
57-
if (&other == this)
57+
if (&other == this) {
5858
return;
59+
}
5960

6061
JNIEnv* env = AttachCurrentThread();
61-
if (obj_)
62+
if (obj_) {
6263
env->DeleteWeakGlobalRef(obj_);
64+
}
6365

6466
obj_ = other.obj_ ? env->NewWeakGlobalRef(other.obj_) : NULL;
6567
}

impeller/renderer/backend/vulkan/command_buffer_vk.cc

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

55
#include "impeller/renderer/backend/vulkan/command_buffer_vk.h"
66

7+
#include <utility>
8+
79
#include "flutter/fml/logging.h"
810
#include "impeller/base/validation.h"
911
#include "impeller/renderer/backend/vulkan/context_vk.h"
@@ -15,7 +17,7 @@
1517
namespace impeller {
1618

1719
std::shared_ptr<CommandBufferVK> CommandBufferVK::Create(
18-
std::weak_ptr<const Context> context,
20+
const std::weak_ptr<const Context>& context,
1921
vk::Device device,
2022
vk::CommandPool command_pool,
2123
SurfaceProducerVK* surface_producer) {
@@ -41,7 +43,7 @@ CommandBufferVK::CommandBufferVK(std::weak_ptr<const Context> context,
4143
SurfaceProducerVK* surface_producer,
4244
vk::CommandPool command_pool,
4345
vk::UniqueCommandBuffer command_buffer)
44-
: CommandBuffer(context),
46+
: CommandBuffer(std::move(context)),
4547
device_(device),
4648
command_pool_(command_pool),
4749
command_buffer_(std::move(command_buffer)),

impeller/renderer/backend/vulkan/command_buffer_vk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace impeller {
1414
class CommandBufferVK final : public CommandBuffer {
1515
public:
1616
static std::shared_ptr<CommandBufferVK> Create(
17-
std::weak_ptr<const Context> context,
17+
const std::weak_ptr<const Context>& context,
1818
vk::Device device,
1919
vk::CommandPool command_pool,
2020
SurfaceProducerVK* surface_producer);

impeller/renderer/backend/vulkan/device_buffer_vk.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ DeviceBufferVK::DeviceBufferVK(
3939
DeviceBufferDescriptor desc,
4040
ContextVK& context,
4141
std::unique_ptr<DeviceBufferAllocationVK> device_allocation)
42-
: DeviceBuffer(std::move(desc)),
42+
: DeviceBuffer(desc),
4343
context_(context),
4444
device_allocation_(std::move(device_allocation)) {}
4545

impeller/renderer/backend/vulkan/pipeline_vk.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ vk::DescriptorSetLayout PipelineCreateInfoVK::GetDescriptorSetLayout() const {
4040
}
4141

4242
PipelineVK::PipelineVK(std::weak_ptr<PipelineLibrary> library,
43-
PipelineDescriptor desc,
43+
const PipelineDescriptor& desc,
4444
std::unique_ptr<PipelineCreateInfoVK> create_info)
45-
: Pipeline(std::move(library), std::move(desc)),
45+
: Pipeline(std::move(library), desc),
4646
pipeline_info_(std::move(create_info)) {}
4747

4848
PipelineVK::~PipelineVK() = default;

impeller/renderer/backend/vulkan/pipeline_vk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PipelineVK final
4343
public BackendCast<PipelineVK, Pipeline<PipelineDescriptor>> {
4444
public:
4545
PipelineVK(std::weak_ptr<PipelineLibrary> library,
46-
PipelineDescriptor desc,
46+
const PipelineDescriptor& desc,
4747
std::unique_ptr<PipelineCreateInfoVK> create_info);
4848

4949
// |Pipeline|

impeller/renderer/backend/vulkan/surface_producer_vk.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "impeller/renderer/backend/vulkan/surface_producer_vk.h"
66

77
#include <array>
8+
#include <utility>
89

910
#include "impeller/base/validation.h"
1011
#include "impeller/renderer/backend/vulkan/surface_vk.h"
@@ -13,7 +14,7 @@
1314
namespace impeller {
1415

1516
std::unique_ptr<SurfaceProducerVK> SurfaceProducerVK::Create(
16-
std::weak_ptr<Context> context,
17+
const std::weak_ptr<Context>& context,
1718
const SurfaceProducerCreateInfoVK& create_info) {
1819
auto surface_producer =
1920
std::make_unique<SurfaceProducerVK>(context, create_info);
@@ -28,7 +29,7 @@ std::unique_ptr<SurfaceProducerVK> SurfaceProducerVK::Create(
2829
SurfaceProducerVK::SurfaceProducerVK(
2930
std::weak_ptr<Context> context,
3031
const SurfaceProducerCreateInfoVK& create_info)
31-
: context_(context), create_info_(create_info) {}
32+
: context_(std::move(context)), create_info_(create_info) {}
3233

3334
SurfaceProducerVK::~SurfaceProducerVK() = default;
3435

impeller/renderer/backend/vulkan/surface_producer_vk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SurfaceSyncObjectsVK {
3333
class SurfaceProducerVK {
3434
public:
3535
static std::unique_ptr<SurfaceProducerVK> Create(
36-
std::weak_ptr<Context> context,
36+
const std::weak_ptr<Context>& context,
3737
const SurfaceProducerCreateInfoVK& create_info);
3838

3939
SurfaceProducerVK(std::weak_ptr<Context> context,

impeller/renderer/backend/vulkan/surface_vk.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ std::unique_ptr<SurfaceVK> SurfaceVK::WrapSwapchainImage(
3434
.frame_num = frame_num,
3535
},
3636
});
37-
color0.texture = std::make_shared<TextureVK>(std::move(color0_tex), context,
37+
color0.texture = std::make_shared<TextureVK>(color0_tex, context,
3838
std::move(color_texture_info));
3939
color0.clear_color = Color::DarkSlateGray();
4040
color0.load_action = LoadAction::kClear;
@@ -59,19 +59,18 @@ std::unique_ptr<SurfaceVK> SurfaceVK::WrapSwapchainImage(
5959
},
6060
});
6161
stencil0.texture = std::make_shared<TextureVK>(
62-
std::move(stencil0_tex), context, std::move(stencil_texture_info));
62+
stencil0_tex, context, std::move(stencil_texture_info));
6363
stencil0.load_action = LoadAction::kClear;
6464
stencil0.store_action = StoreAction::kDontCare;
6565

6666
RenderTarget render_target_desc;
6767
render_target_desc.SetColorAttachment(color0, 0u);
6868

69-
return std::unique_ptr<SurfaceVK>(new SurfaceVK(std::move(render_target_desc),
70-
swapchain_image,
71-
std::move(swap_callback)));
69+
return std::unique_ptr<SurfaceVK>(new SurfaceVK(
70+
render_target_desc, swapchain_image, std::move(swap_callback)));
7271
}
7372

74-
SurfaceVK::SurfaceVK(RenderTarget target,
73+
SurfaceVK::SurfaceVK(const RenderTarget& target,
7574
SwapchainImageVK* swapchain_image,
7675
SwapCallback swap_callback)
7776
: Surface(target) {

impeller/renderer/backend/vulkan/surface_vk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SurfaceVK final : public Surface {
2323
ContextVK* context,
2424
SwapCallback swap_callback);
2525

26-
SurfaceVK(RenderTarget target,
26+
SurfaceVK(const RenderTarget& target,
2727
SwapchainImageVK* swapchain_image,
2828
SwapCallback swap_callback);
2929

impeller/toolkit/egl/config.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace impeller {
1010
namespace egl {
1111

1212
Config::Config(ConfigDescriptor descriptor, EGLConfig config)
13-
: desc_(std::move(descriptor)), config_(config) {}
13+
: desc_(descriptor), config_(config) {}
1414

1515
Config::~Config() = default;
1616

impeller/toolkit/egl/context.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ bool Context::ClearCurrent() const {
7272
}
7373

7474
std::optional<UniqueID> Context::AddLifecycleListener(
75-
LifecycleListener listener) {
75+
const LifecycleListener& listener) {
7676
if (!listener) {
7777
return std::nullopt;
7878
}

impeller/toolkit/egl/context.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class Context {
3535
kWillClearCurrent,
3636
};
3737
using LifecycleListener = std::function<void(LifecycleEvent)>;
38-
std::optional<UniqueID> AddLifecycleListener(LifecycleListener listener);
38+
std::optional<UniqueID> AddLifecycleListener(
39+
const LifecycleListener& listener);
3940

4041
bool RemoveLifecycleListener(UniqueID id);
4142

impeller/toolkit/egl/display.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ std::unique_ptr<Config> Display::ChooseConfig(ConfigDescriptor config) const {
166166
return nullptr;
167167
}
168168

169-
return std::make_unique<Config>(std::move(config), config_out);
169+
return std::make_unique<Config>(config, config_out);
170170
}
171171

172172
std::unique_ptr<Surface> Display::CreateWindowSurface(

lib/ui/ui_dart_state.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void UIDartState::LogMessage(const std::string& tag,
215215
// Fall back to previous behavior if unspecified.
216216
#if defined(FML_OS_ANDROID)
217217
__android_log_print(ANDROID_LOG_INFO, tag.c_str(), "%.*s",
218-
(int)message.size(), message.c_str());
218+
static_cast<int>(message.size()), message.c_str());
219219
#elif defined(FML_OS_IOS)
220220
std::stringstream stream;
221221
if (!tag.empty()) {

shell/platform/android/android_context_gl_skia.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ AndroidContextGLSkia::AndroidContextGLSkia(
7070
const TaskRunners& task_runners,
7171
uint8_t msaa_samples)
7272
: AndroidContext(AndroidRenderingAPI::kOpenGLES),
73-
environment_(environment),
73+
environment_(std::move(environment)),
7474
config_(nullptr),
7575
task_runners_(task_runners) {
7676
if (!environment_->IsValid()) {
@@ -146,7 +146,7 @@ AndroidContextGLSkia::~AndroidContextGLSkia() {
146146
}
147147

148148
std::unique_ptr<AndroidEGLSurface> AndroidContextGLSkia::CreateOnscreenSurface(
149-
fml::RefPtr<AndroidNativeWindow> window) const {
149+
const fml::RefPtr<AndroidNativeWindow>& window) const {
150150
if (window->IsFakeWindow()) {
151151
return CreatePbufferSurface();
152152
} else {

shell/platform/android/android_context_gl_skia.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class AndroidContextGLSkia : public AndroidContext {
4141
/// @return The window surface.
4242
///
4343
std::unique_ptr<AndroidEGLSurface> CreateOnscreenSurface(
44-
fml::RefPtr<AndroidNativeWindow> window) const;
44+
const fml::RefPtr<AndroidNativeWindow>& window) const;
4545

4646
//----------------------------------------------------------------------------
4747
/// @brief Allocates an 1x1 pbuffer surface that is used for making the

shell/platform/android/android_external_texture_gl.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include <GLES/glext.h>
88

9+
#include <utility>
10+
911
#include "third_party/skia/include/core/SkAlphaType.h"
1012
#include "third_party/skia/include/core/SkColorSpace.h"
1113
#include "third_party/skia/include/core/SkColorType.h"
@@ -20,7 +22,7 @@ AndroidExternalTextureGL::AndroidExternalTextureGL(
2022
const fml::jni::ScopedJavaGlobalRef<jobject>& surface_texture,
2123
std::shared_ptr<PlatformViewAndroidJNI> jni_facade)
2224
: Texture(id),
23-
jni_facade_(jni_facade),
25+
jni_facade_(std::move(jni_facade)),
2426
surface_texture_(surface_texture),
2527
transform(SkMatrix::I()) {}
2628

shell/platform/android/android_image_generator.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "flutter/shell/platform/android/android_image_generator.h"
66

77
#include <memory>
8+
#include <utility>
89

910
#include <android/bitmap.h>
1011
#include <android/hardware_buffer.h>
@@ -21,7 +22,7 @@ static jmethodID g_decode_image_method = nullptr;
2122
AndroidImageGenerator::~AndroidImageGenerator() = default;
2223

2324
AndroidImageGenerator::AndroidImageGenerator(sk_sp<SkData> data)
24-
: data_(data), image_info_(SkImageInfo::MakeUnknown(-1, -1)) {}
25+
: data_(std::move(data)), image_info_(SkImageInfo::MakeUnknown(-1, -1)) {}
2526

2627
const SkImageInfo& AndroidImageGenerator::GetInfo() {
2728
header_decoded_latch_.Wait();
@@ -173,7 +174,7 @@ bool AndroidImageGenerator::Register(JNIEnv* env) {
173174

174175
std::shared_ptr<ImageGenerator> AndroidImageGenerator::MakeFromData(
175176
sk_sp<SkData> data,
176-
fml::RefPtr<fml::TaskRunner> task_runner) {
177+
const fml::RefPtr<fml::TaskRunner>& task_runner) {
177178
std::shared_ptr<AndroidImageGenerator> generator(
178179
new AndroidImageGenerator(std::move(data)));
179180

shell/platform/android/android_image_generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class AndroidImageGenerator : public ImageGenerator {
5050

5151
static std::shared_ptr<ImageGenerator> MakeFromData(
5252
sk_sp<SkData> data,
53-
fml::RefPtr<fml::TaskRunner> task_runner);
53+
const fml::RefPtr<fml::TaskRunner>& task_runner);
5454

5555
static void NativeImageHeaderCallback(JNIEnv* env,
5656
jclass jcaller,

shell/platform/android/android_shell_holder.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ static PlatformData GetDefaultPlatformData() {
7878
}
7979

8080
AndroidShellHolder::AndroidShellHolder(
81-
flutter::Settings settings,
81+
const flutter::Settings& settings,
8282
std::shared_ptr<PlatformViewAndroidJNI> jni_facade)
83-
: settings_(std::move(settings)), jni_facade_(jni_facade) {
83+
: settings_(settings), jni_facade_(jni_facade) {
8484
static size_t thread_host_count = 1;
8585
auto thread_label = std::to_string(thread_host_count++);
8686

@@ -164,7 +164,7 @@ AndroidShellHolder::AndroidShellHolder(
164164

165165
shell_->RegisterImageDecoder(
166166
[runner = task_runners.GetIOTaskRunner()](sk_sp<SkData> buffer) {
167-
return AndroidImageGenerator::MakeFromData(buffer, runner);
167+
return AndroidImageGenerator::MakeFromData(std::move(buffer), runner);
168168
},
169169
-1);
170170
FML_DLOG(INFO) << "Registered Android SDK image decoder (API level 28+)";
@@ -181,7 +181,7 @@ AndroidShellHolder::AndroidShellHolder(
181181
const std::shared_ptr<ThreadHost>& thread_host,
182182
std::unique_ptr<Shell> shell,
183183
const fml::WeakPtr<PlatformViewAndroid>& platform_view)
184-
: settings_(std::move(settings)),
184+
: settings_(settings),
185185
jni_facade_(jni_facade),
186186
platform_view_(platform_view),
187187
thread_host_(thread_host),
@@ -335,13 +335,12 @@ std::optional<RunConfiguration> AndroidShellHolder::BuildRunConfiguration(
335335

336336
{
337337
if (!entrypoint.empty() && !libraryUrl.empty()) {
338-
config.SetEntrypointAndLibrary(std::move(entrypoint),
339-
std::move(libraryUrl));
338+
config.SetEntrypointAndLibrary(entrypoint, libraryUrl);
340339
} else if (!entrypoint.empty()) {
341-
config.SetEntrypoint(std::move(entrypoint));
340+
config.SetEntrypoint(entrypoint);
342341
}
343342
if (!entrypoint_args.empty()) {
344-
config.SetEntrypointArgs(std::move(entrypoint_args));
343+
config.SetEntrypointArgs(entrypoint_args);
345344
}
346345
}
347346
return config;

shell/platform/android/android_shell_holder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace flutter {
4141
///
4242
class AndroidShellHolder {
4343
public:
44-
AndroidShellHolder(flutter::Settings settings,
44+
AndroidShellHolder(const flutter::Settings& settings,
4545
std::shared_ptr<PlatformViewAndroidJNI> jni_facade);
4646

4747
~AndroidShellHolder();

shell/platform/android/android_surface_gl_impeller.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class AndroidSurfaceGLImpeller::ReactorWorker final
4646
};
4747

4848
static std::shared_ptr<impeller::Context> CreateImpellerContext(
49-
std::shared_ptr<impeller::ReactorGLES::Worker> worker) {
49+
const std::shared_ptr<impeller::ReactorGLES::Worker>& worker) {
5050
auto proc_table = std::make_unique<impeller::ProcTableGLES>(
5151
impeller::egl::CreateProcAddressResolver());
5252

@@ -68,7 +68,7 @@ static std::shared_ptr<impeller::Context> CreateImpellerContext(
6868
return nullptr;
6969
}
7070

71-
if (!context->AddReactorWorker(std::move(worker)).has_value()) {
71+
if (!context->AddReactorWorker(worker).has_value()) {
7272
FML_LOG(ERROR) << "Could not add reactor worker.";
7373
return nullptr;
7474
}
@@ -78,7 +78,7 @@ static std::shared_ptr<impeller::Context> CreateImpellerContext(
7878

7979
AndroidSurfaceGLImpeller::AndroidSurfaceGLImpeller(
8080
const std::shared_ptr<AndroidContext>& android_context,
81-
std::shared_ptr<PlatformViewAndroidJNI> jni_facade)
81+
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)
8282
: AndroidSurface(android_context),
8383
reactor_worker_(std::shared_ptr<ReactorWorker>(new ReactorWorker())) {
8484
auto display = std::make_unique<impeller::egl::Display>();

shell/platform/android/android_surface_gl_impeller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AndroidSurfaceGLImpeller final : public GPUSurfaceGLDelegate,
1919
public:
2020
AndroidSurfaceGLImpeller(
2121
const std::shared_ptr<AndroidContext>& android_context,
22-
std::shared_ptr<PlatformViewAndroidJNI> jni_facade);
22+
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade);
2323

2424
// |AndroidSurface|
2525
~AndroidSurfaceGLImpeller() override;

0 commit comments

Comments
 (0)