Skip to content

Commit 8fdb92c

Browse files
authored
Removed instances of unnecessary values (flutter#36221)
1 parent 2788964 commit 8fdb92c

File tree

290 files changed

+1191
-1045
lines changed

Some content is hidden

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

290 files changed

+1191
-1045
lines changed

.clang-tidy

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ readability-identifier-naming,\
1010
-clang-analyzer-nullability.NullPassedToNonnull,\
1111
-clang-analyzer-nullability.NullablePassedToNonnull,\
1212
-clang-analyzer-nullability.NullReturnedFromNonnull,\
13-
-clang-analyzer-nullability.NullableReturnedFromNonnull"
13+
-clang-analyzer-nullability.NullableReturnedFromNonnull,\
14+
performance-move-const-arg,\
15+
performance-unnecessary-value-param"
1416

1517
# Only warnings treated as errors are reported
1618
# in the "ci/lint.sh" script and pre-push git hook.

common/graphics/persistent_cache.cc

+10-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <memory>
99
#include <string>
1010
#include <string_view>
11+
#include <utility>
1112

1213
#include "flutter/fml/base32.h"
1314
#include "flutter/fml/file.h"
@@ -74,7 +75,7 @@ void PersistentCache::ResetCacheForProcess() {
7475
}
7576

7677
void PersistentCache::SetCacheDirectoryPath(std::string path) {
77-
cache_base_path_ = path;
78+
cache_base_path_ = std::move(path);
7879
}
7980

8081
bool PersistentCache::Purge() {
@@ -343,10 +344,11 @@ sk_sp<SkData> PersistentCache::load(const SkData& key) {
343344
return result;
344345
}
345346

346-
static void PersistentCacheStore(fml::RefPtr<fml::TaskRunner> worker,
347-
std::shared_ptr<fml::UniqueFD> cache_directory,
348-
std::string key,
349-
std::unique_ptr<fml::Mapping> value) {
347+
static void PersistentCacheStore(
348+
const fml::RefPtr<fml::TaskRunner>& worker,
349+
const std::shared_ptr<fml::UniqueFD>& cache_directory,
350+
std::string key,
351+
std::unique_ptr<fml::Mapping> value) {
350352
// The static leak checker gets confused by the use of fml::MakeCopyable.
351353
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
352354
auto task = fml::MakeCopyable([cache_directory, //
@@ -440,13 +442,13 @@ void PersistentCache::DumpSkp(const SkData& data) {
440442
}
441443

442444
void PersistentCache::AddWorkerTaskRunner(
443-
fml::RefPtr<fml::TaskRunner> task_runner) {
445+
const fml::RefPtr<fml::TaskRunner>& task_runner) {
444446
std::scoped_lock lock(worker_task_runners_mutex_);
445447
worker_task_runners_.insert(task_runner);
446448
}
447449

448450
void PersistentCache::RemoveWorkerTaskRunner(
449-
fml::RefPtr<fml::TaskRunner> task_runner) {
451+
const fml::RefPtr<fml::TaskRunner>& task_runner) {
450452
std::scoped_lock lock(worker_task_runners_mutex_);
451453
auto found = worker_task_runners_.find(task_runner);
452454
if (found != worker_task_runners_.end()) {
@@ -467,7 +469,7 @@ fml::RefPtr<fml::TaskRunner> PersistentCache::GetWorkerTaskRunner() const {
467469

468470
void PersistentCache::SetAssetManager(std::shared_ptr<AssetManager> value) {
469471
TRACE_EVENT_INSTANT0("flutter", "PersistentCache::SetAssetManager");
470-
asset_manager_ = value;
472+
asset_manager_ = std::move(value);
471473
}
472474

473475
std::vector<std::unique_ptr<fml::Mapping>>

common/graphics/persistent_cache.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ class PersistentCache : public GrContextOptions::PersistentCache {
6868

6969
~PersistentCache() override;
7070

71-
void AddWorkerTaskRunner(fml::RefPtr<fml::TaskRunner> task_runner);
71+
void AddWorkerTaskRunner(const fml::RefPtr<fml::TaskRunner>& task_runner);
7272

73-
void RemoveWorkerTaskRunner(fml::RefPtr<fml::TaskRunner> task_runner);
73+
void RemoveWorkerTaskRunner(const fml::RefPtr<fml::TaskRunner>& task_runner);
7474

7575
// Whether Skia tries to store any shader into this persistent cache after
7676
// |ResetStoredNewShaders| is called. This flag is usually reset before each

common/graphics/texture.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Texture::~Texture() = default;
1616

1717
TextureRegistry::TextureRegistry() = default;
1818

19-
void TextureRegistry::RegisterTexture(std::shared_ptr<Texture> texture) {
19+
void TextureRegistry::RegisterTexture(const std::shared_ptr<Texture>& texture) {
2020
if (!texture) {
2121
return;
2222
}

common/graphics/texture.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class TextureRegistry {
6262
TextureRegistry();
6363

6464
// Called from raster thread.
65-
void RegisterTexture(std::shared_ptr<Texture> texture);
65+
void RegisterTexture(const std::shared_ptr<Texture>& texture);
6666

6767
// Called from raster thread.
6868
void RegisterContextListener(uintptr_t id,

display_list/display_list_builder.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ void DisplayListBuilder::drawImage(const sk_sp<DlImage> image,
897897
: Push<DrawImageOp>(0, 1, std::move(image), point, sampling);
898898
CheckLayerOpacityCompatibility(render_with_attributes);
899899
}
900-
void DisplayListBuilder::drawImage(const sk_sp<DlImage> image,
900+
void DisplayListBuilder::drawImage(const sk_sp<DlImage>& image,
901901
const SkPoint point,
902902
DlImageSampling sampling,
903903
const DlPaint* paint) {
@@ -919,7 +919,7 @@ void DisplayListBuilder::drawImageRect(const sk_sp<DlImage> image,
919919
render_with_attributes, constraint);
920920
CheckLayerOpacityCompatibility(render_with_attributes);
921921
}
922-
void DisplayListBuilder::drawImageRect(const sk_sp<DlImage> image,
922+
void DisplayListBuilder::drawImageRect(const sk_sp<DlImage>& image,
923923
const SkRect& src,
924924
const SkRect& dst,
925925
DlImageSampling sampling,
@@ -944,7 +944,7 @@ void DisplayListBuilder::drawImageNine(const sk_sp<DlImage> image,
944944
: Push<DrawImageNineOp>(0, 1, std::move(image), center, dst, filter);
945945
CheckLayerOpacityCompatibility(render_with_attributes);
946946
}
947-
void DisplayListBuilder::drawImageNine(const sk_sp<DlImage> image,
947+
void DisplayListBuilder::drawImageNine(const sk_sp<DlImage>& image,
948948
const SkIRect& center,
949949
const SkRect& dst,
950950
DlFilterMode filter,
@@ -1017,7 +1017,7 @@ void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
10171017
// of the transforms and texture rectangles.
10181018
UpdateLayerOpacityCompatibility(false);
10191019
}
1020-
void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
1020+
void DisplayListBuilder::drawAtlas(const sk_sp<DlImage>& atlas,
10211021
const SkRSXform xform[],
10221022
const SkRect tex[],
10231023
const DlColor colors[],

display_list/display_list_builder.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class DisplayListBuilder final : public virtual Dispatcher,
275275
const SkPoint point,
276276
DlImageSampling sampling,
277277
bool render_with_attributes) override;
278-
void drawImage(const sk_sp<DlImage> image,
278+
void drawImage(const sk_sp<DlImage>& image,
279279
const SkPoint point,
280280
DlImageSampling sampling,
281281
const DlPaint* paint = nullptr);
@@ -287,7 +287,7 @@ class DisplayListBuilder final : public virtual Dispatcher,
287287
bool render_with_attributes,
288288
SkCanvas::SrcRectConstraint constraint =
289289
SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint) override;
290-
void drawImageRect(const sk_sp<DlImage> image,
290+
void drawImageRect(const sk_sp<DlImage>& image,
291291
const SkRect& src,
292292
const SkRect& dst,
293293
DlImageSampling sampling,
@@ -299,7 +299,7 @@ class DisplayListBuilder final : public virtual Dispatcher,
299299
const SkRect& dst,
300300
DlFilterMode filter,
301301
bool render_with_attributes) override;
302-
void drawImageNine(const sk_sp<DlImage> image,
302+
void drawImageNine(const sk_sp<DlImage>& image,
303303
const SkIRect& center,
304304
const SkRect& dst,
305305
DlFilterMode filter,
@@ -318,7 +318,7 @@ class DisplayListBuilder final : public virtual Dispatcher,
318318
DlImageSampling sampling,
319319
const SkRect* cullRect,
320320
bool render_with_attributes) override;
321-
void drawAtlas(const sk_sp<DlImage> atlas,
321+
void drawAtlas(const sk_sp<DlImage>& atlas,
322322
const SkRSXform xform[],
323323
const SkRect tex[],
324324
const DlColor colors[],

display_list/display_list_canvas_unittests.cc

+21-18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#include <utility>
6+
57
#include "flutter/display_list/display_list.h"
68
#include "flutter/display_list/display_list_canvas_dispatcher.h"
79
#include "flutter/display_list/display_list_canvas_recorder.h"
@@ -239,7 +241,8 @@ static void EmptyDlRenderer(DisplayListBuilder&) {}
239241

240242
class RenderSurface {
241243
public:
242-
explicit RenderSurface(sk_sp<SkSurface> surface) : surface_(surface) {
244+
explicit RenderSurface(sk_sp<SkSurface> surface)
245+
: surface_(std::move(surface)) {
243246
EXPECT_EQ(canvas()->save(), 1);
244247
}
245248
~RenderSurface() { sk_free(addr_); }
@@ -597,10 +600,10 @@ class TestParameters {
597600
class CaseParameters {
598601
public:
599602
explicit CaseParameters(std::string info)
600-
: CaseParameters(info, EmptyCvRenderer, EmptyDlRenderer) {}
603+
: CaseParameters(std::move(info), EmptyCvRenderer, EmptyDlRenderer) {}
601604

602-
CaseParameters(std::string info, CvSetup cv_setup, DlRenderer dl_setup)
603-
: CaseParameters(info,
605+
CaseParameters(std::string info, CvSetup& cv_setup, DlRenderer& dl_setup)
606+
: CaseParameters(std::move(info),
604607
cv_setup,
605608
dl_setup,
606609
EmptyCvRenderer,
@@ -611,15 +614,15 @@ class CaseParameters {
611614
false) {}
612615

613616
CaseParameters(std::string info,
614-
CvSetup cv_setup,
615-
DlRenderer dl_setup,
616-
CvRenderer cv_restore,
617-
DlRenderer dl_restore,
617+
CvSetup& cv_setup,
618+
DlRenderer& dl_setup,
619+
CvRenderer& cv_restore,
620+
DlRenderer& dl_restore,
618621
DlColor bg,
619622
bool has_diff_clip,
620623
bool has_mutating_save_layer,
621624
bool fuzzy_compare_components)
622-
: info_(info),
625+
: info_(std::move(info)),
623626
bg_(bg),
624627
cv_setup_(cv_setup),
625628
dl_setup_(dl_setup),
@@ -629,8 +632,8 @@ class CaseParameters {
629632
has_mutating_save_layer_(has_mutating_save_layer),
630633
fuzzy_compare_components_(fuzzy_compare_components) {}
631634

632-
CaseParameters with_restore(CvRenderer cv_restore,
633-
DlRenderer dl_restore,
635+
CaseParameters with_restore(CvRenderer& cv_restore,
636+
DlRenderer& dl_restore,
634637
bool mutating_layer,
635638
bool fuzzy_compare_components = false) {
636639
return CaseParameters(info_, cv_setup_, dl_setup_, cv_restore, dl_restore,
@@ -1945,9 +1948,9 @@ class CanvasCompareTester {
19451948
}
19461949

19471950
static void checkGroupOpacity(const RenderEnvironment& env,
1948-
sk_sp<DisplayList> display_list,
1951+
const sk_sp<DisplayList>& display_list,
19491952
const SkPixmap* ref_pixmap,
1950-
const std::string info,
1953+
const std::string& info,
19511954
DlColor bg) {
19521955
SkScalar opacity = 128.0 / 255.0;
19531956

@@ -2002,7 +2005,7 @@ class CanvasCompareTester {
20022005

20032006
static void checkPixels(const SkPixmap* ref_pixels,
20042007
const SkRect ref_bounds,
2005-
const std::string info,
2008+
const std::string& info,
20062009
const DlColor bg) {
20072010
uint32_t untouched = bg.premultipliedArgb();
20082011
int pixels_touched = 0;
@@ -2026,7 +2029,7 @@ class CanvasCompareTester {
20262029
static void quickCompareToReference(const SkPixmap* ref_pixels,
20272030
const SkPixmap* test_pixels,
20282031
bool should_match,
2029-
const std::string info) {
2032+
const std::string& info) {
20302033
ASSERT_EQ(test_pixels->width(), ref_pixels->width()) << info;
20312034
ASSERT_EQ(test_pixels->height(), ref_pixels->height()) << info;
20322035
ASSERT_EQ(test_pixels->info().bytesPerPixel(), 4) << info;
@@ -2050,7 +2053,7 @@ class CanvasCompareTester {
20502053

20512054
static void compareToReference(const SkPixmap* test_pixels,
20522055
const SkPixmap* ref_pixels,
2053-
const std::string info,
2056+
const std::string& info,
20542057
SkRect* bounds,
20552058
const BoundsTolerance* tolerance,
20562059
const DlColor bg,
@@ -2121,7 +2124,7 @@ class CanvasCompareTester {
21212124
ASSERT_EQ(pixels_different, 0) << info;
21222125
}
21232126

2124-
static void showBoundsOverflow(std::string info,
2127+
static void showBoundsOverflow(const std::string& info,
21252128
SkIRect& bounds,
21262129
const BoundsTolerance* tolerance,
21272130
int pixLeft,
@@ -2186,7 +2189,7 @@ class CanvasCompareTester {
21862189

21872190
static const DlImageColorSource kTestImageColorSource;
21882191

2189-
static sk_sp<SkTextBlob> MakeTextBlob(std::string string,
2192+
static sk_sp<SkTextBlob> MakeTextBlob(const std::string& string,
21902193
SkScalar font_height) {
21912194
SkFont font(SkTypeface::MakeFromName("ahem", SkFontStyle::Normal()),
21922195
font_height);

display_list/display_list_mask_filter_unittests.cc

+7-6
Original file line numberDiff line numberDiff line change
@@ -131,33 +131,34 @@ void testNotEquals(DlMaskFilter* a, DlMaskFilter* b) {
131131
ASSERT_TRUE(NotEquals(b, a));
132132
}
133133

134-
void testEquals(std::shared_ptr<const DlMaskFilter> a, DlMaskFilter* b) {
134+
void testEquals(const std::shared_ptr<const DlMaskFilter>& a, DlMaskFilter* b) {
135135
// a and b have the same nullness or values
136136
ASSERT_TRUE(Equals(a, b));
137137
ASSERT_FALSE(NotEquals(a, b));
138138
ASSERT_TRUE(Equals(b, a));
139139
ASSERT_FALSE(NotEquals(b, a));
140140
}
141141

142-
void testNotEquals(std::shared_ptr<const DlMaskFilter> a, DlMaskFilter* b) {
142+
void testNotEquals(const std::shared_ptr<const DlMaskFilter>& a,
143+
DlMaskFilter* b) {
143144
// a and b do not have the same nullness or values
144145
ASSERT_FALSE(Equals(a, b));
145146
ASSERT_TRUE(NotEquals(a, b));
146147
ASSERT_FALSE(Equals(b, a));
147148
ASSERT_TRUE(NotEquals(b, a));
148149
}
149150

150-
void testEquals(std::shared_ptr<const DlMaskFilter> a,
151-
std::shared_ptr<const DlMaskFilter> b) {
151+
void testEquals(const std::shared_ptr<const DlMaskFilter>& a,
152+
const std::shared_ptr<const DlMaskFilter>& b) {
152153
// a and b have the same nullness or values
153154
ASSERT_TRUE(Equals(a, b));
154155
ASSERT_FALSE(NotEquals(a, b));
155156
ASSERT_TRUE(Equals(b, a));
156157
ASSERT_FALSE(NotEquals(b, a));
157158
}
158159

159-
void testNotEquals(std::shared_ptr<const DlMaskFilter> a,
160-
std::shared_ptr<const DlMaskFilter> b) {
160+
void testNotEquals(const std::shared_ptr<const DlMaskFilter>& a,
161+
const std::shared_ptr<const DlMaskFilter>& b) {
161162
// a and b do not have the same nullness or values
162163
ASSERT_FALSE(Equals(a, b));
163164
ASSERT_TRUE(NotEquals(a, b));

display_list/display_list_unittests.cc

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <memory>
66
#include <string>
77
#include <unordered_set>
8+
#include <utility>
89
#include <vector>
910

1011
#include "flutter/display_list/display_list.h"
@@ -591,7 +592,7 @@ TEST(DisplayList, DisplayListTransformResetHandling) {
591592
}
592593

593594
TEST(DisplayList, SingleOpsMightSupportGroupOpacityWithOrWithoutBlendMode) {
594-
auto run_tests = [](std::string name,
595+
auto run_tests = [](const std::string& name,
595596
void build(DisplayListBuilder & builder),
596597
bool expect_for_op, bool expect_with_kSrc) {
597598
{
@@ -783,12 +784,12 @@ class SaveLayerOptionsExpector : public virtual Dispatcher,
783784
public IgnoreTransformDispatchHelper,
784785
public IgnoreDrawDispatchHelper {
785786
public:
786-
explicit SaveLayerOptionsExpector(SaveLayerOptions expected) {
787+
explicit SaveLayerOptionsExpector(const SaveLayerOptions& expected) {
787788
expected_.push_back(expected);
788789
}
789790

790791
explicit SaveLayerOptionsExpector(std::vector<SaveLayerOptions> expected)
791-
: expected_(expected) {}
792+
: expected_(std::move(expected)) {}
792793

793794
void saveLayer(const SkRect* bounds,
794795
const SaveLayerOptions options,
@@ -1541,10 +1542,10 @@ TEST(DisplayList, FlatDrawPointsProducesBounds) {
15411542
}
15421543
}
15431544

1544-
static void test_rtree(sk_sp<const DlRTree> rtree,
1545+
static void test_rtree(const sk_sp<const DlRTree>& rtree,
15451546
const SkRect& query,
15461547
std::vector<SkRect> expected_rects,
1547-
std::vector<int> expected_indices) {
1548+
const std::vector<int>& expected_indices) {
15481549
std::vector<int> indices;
15491550
rtree->search(query, &indices);
15501551
EXPECT_EQ(indices, expected_indices);

flow/compositor_context.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "flutter/flow/compositor_context.h"
66

77
#include <optional>
8+
#include <utility>
89
#include "flutter/flow/layers/layer_tree.h"
910
#include "third_party/skia/include/core/SkCanvas.h"
1011

@@ -106,7 +107,7 @@ CompositorContext::ScopedFrame::ScopedFrame(
106107
root_surface_transformation_(root_surface_transformation),
107108
instrumentation_enabled_(instrumentation_enabled),
108109
surface_supports_readback_(surface_supports_readback),
109-
raster_thread_merger_(raster_thread_merger) {
110+
raster_thread_merger_(std::move(raster_thread_merger)) {
110111
context_.BeginFrame(*this, instrumentation_enabled_);
111112
}
112113

0 commit comments

Comments
 (0)