From 46fa69159616860ded192643031f7cb3c10b818b Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 27 Mar 2020 18:30:35 +0200 Subject: [core] Fix performance-unnecessary-value-param errors in header files As reported by clang-tidy-8. --- include/mbgl/actor/scheduler.hpp | 2 +- include/mbgl/style/expression/case.hpp | 4 ++-- include/mbgl/style/expression/let.hpp | 7 ++----- include/mbgl/style/expression/literal.hpp | 12 +++--------- include/mbgl/style/expression/match.hpp | 13 ++++++------- include/mbgl/style/expression/parsing_context.hpp | 20 ++++++++++---------- include/mbgl/style/image.hpp | 11 +++-------- include/mbgl/util/thread.hpp | 4 ++-- platform/glfw/glfw_view.hpp | 14 +++++--------- src/mbgl/style/properties.hpp | 5 +---- src/mbgl/tile/tile_loader_impl.hpp | 4 ++-- 11 files changed, 37 insertions(+), 59 deletions(-) diff --git a/include/mbgl/actor/scheduler.hpp b/include/mbgl/actor/scheduler.hpp index cdaf185c8b..1a9ba1907f 100644 --- a/include/mbgl/actor/scheduler.hpp +++ b/include/mbgl/actor/scheduler.hpp @@ -90,7 +90,7 @@ protected: template void scheduleAndReplyValue(const TaskFn& task, const ReplyFn& reply, - mapbox::base::WeakPtr replyScheduler) { + const mapbox::base::WeakPtr& replyScheduler) { auto scheduled = [replyScheduler, task, reply] { auto lock = replyScheduler.lock(); if (!replyScheduler) return; diff --git a/include/mbgl/style/expression/case.hpp b/include/mbgl/style/expression/case.hpp index 7cd007d3c7..4a254dc35b 100644 --- a/include/mbgl/style/expression/case.hpp +++ b/include/mbgl/style/expression/case.hpp @@ -5,6 +5,7 @@ #include #include +#include #include namespace mbgl { @@ -16,8 +17,7 @@ public: using Branch = std::pair, std::unique_ptr>; Case(type::Type type_, std::vector branches_, std::unique_ptr otherwise_) - : Expression(Kind::Case, type_), branches(std::move(branches_)), otherwise(std::move(otherwise_)) { - } + : Expression(Kind::Case, std::move(type_)), branches(std::move(branches_)), otherwise(std::move(otherwise_)) {} static ParseResult parse(const mbgl::style::conversion::Convertible& value, ParsingContext& ctx); diff --git a/include/mbgl/style/expression/let.hpp b/include/mbgl/style/expression/let.hpp index d11ba1b976..7c468dfeb1 100644 --- a/include/mbgl/style/expression/let.hpp +++ b/include/mbgl/style/expression/let.hpp @@ -49,11 +49,8 @@ private: class Var : public Expression { public: - Var(std::string name_, std::shared_ptr value_) : - Expression(Kind::Var, value_->getType()), - name(std::move(name_)), - value(value_) - {} + Var(std::string name_, const std::shared_ptr& value_) + : Expression(Kind::Var, value_->getType()), name(std::move(name_)), value(value_) {} static ParseResult parse(const mbgl::style::conversion::Convertible&, ParsingContext&); diff --git a/include/mbgl/style/expression/literal.hpp b/include/mbgl/style/expression/literal.hpp index bcae23b1fa..f704a34a59 100644 --- a/include/mbgl/style/expression/literal.hpp +++ b/include/mbgl/style/expression/literal.hpp @@ -12,15 +12,9 @@ namespace expression { class Literal : public Expression { public: - Literal(Value value_) - : Expression(Kind::Literal, typeOf(value_)) - , value(value_) - {} - - Literal(type::Array type_, std::vector value_) - : Expression(Kind::Literal, type_) - , value(value_) - {} + Literal(const Value& value_) : Expression(Kind::Literal, typeOf(value_)), value(value_) {} + + Literal(const type::Array& type_, std::vector value_) : Expression(Kind::Literal, type_), value(value_) {} EvaluationResult evaluate(const EvaluationContext&) const override { return value; diff --git a/include/mbgl/style/expression/match.hpp b/include/mbgl/style/expression/match.hpp index 2ce4b7a533..766eec8f5a 100644 --- a/include/mbgl/style/expression/match.hpp +++ b/include/mbgl/style/expression/match.hpp @@ -15,15 +15,14 @@ class Match : public Expression { public: using Branches = std::unordered_map>; - Match(type::Type type_, + Match(const type::Type& type_, std::unique_ptr input_, Branches branches_, - std::unique_ptr otherwise_ - ) : Expression(Kind::Match, type_), - input(std::move(input_)), - branches(std::move(branches_)), - otherwise(std::move(otherwise_)) - {} + std::unique_ptr otherwise_) + : Expression(Kind::Match, type_), + input(std::move(input_)), + branches(std::move(branches_)), + otherwise(std::move(otherwise_)) {} EvaluationResult evaluate(const EvaluationContext& params) const override; diff --git a/include/mbgl/style/expression/parsing_context.hpp b/include/mbgl/style/expression/parsing_context.hpp index d1e209989f..31445271a9 100644 --- a/include/mbgl/style/expression/parsing_context.hpp +++ b/include/mbgl/style/expression/parsing_context.hpp @@ -7,10 +7,11 @@ #include #include -#include +#include #include +#include +#include #include -#include namespace mbgl { namespace style { @@ -122,22 +123,21 @@ public: Check whether `t` is a subtype of `expected`, collecting an error if not. */ optional checkType(const type::Type& t); - - optional> getBinding(const std::string name) { + + optional> getBinding(const std::string& name) { if (!scope) return optional>(); return scope->get(name); } - void error(std::string message) { - errors->push_back({message, key}); - } - + void error(std::string message) { errors->push_back({std::move(message), key}); } + void error(std::string message, std::size_t child) { - errors->push_back({message, key + "[" + util::toString(child) + "]"}); + errors->push_back({std::move(message), key + "[" + util::toString(child) + "]"}); } void error(std::string message, std::size_t child, std::size_t grandchild) { - errors->push_back({message, key + "[" + util::toString(child) + "][" + util::toString(grandchild) + "]"}); + errors->push_back( + {std::move(message), key + "[" + util::toString(child) + "][" + util::toString(grandchild) + "]"}); } void appendErrors(ParsingContext&& ctx) { diff --git a/include/mbgl/style/image.hpp b/include/mbgl/style/image.hpp index d551651cd0..5783fc2468 100644 --- a/include/mbgl/style/image.hpp +++ b/include/mbgl/style/image.hpp @@ -40,14 +40,9 @@ public: float pixelRatio, ImageStretches stretchX = {}, ImageStretches stretchY = {}, - optional content = nullopt) - : Image(std::move(id), - std::move(image), - pixelRatio, - false, - std::move(stretchX), - std::move(stretchY), - content) {} + const optional& content = nullopt) + : Image(std::move(id), std::move(image), pixelRatio, false, std::move(stretchX), std::move(stretchY), content) { + } Image(const Image&); std::string getID() const; diff --git a/include/mbgl/util/thread.hpp b/include/mbgl/util/thread.hpp index 4bc948fdbd..7a9b741703 100644 --- a/include/mbgl/util/thread.hpp +++ b/include/mbgl/util/thread.hpp @@ -77,8 +77,8 @@ public: : Thread([] { platform::makeThreadLowPriority(); }, name, std::make_tuple(std::forward(args)...)) {} template - Thread(std::function prioritySetter, const std::string& name, Args&&... args) - : Thread(std::move(prioritySetter), name, std::make_tuple(std::forward(args)...)) {} + Thread(const std::function& prioritySetter, const std::string& name, Args&&... args) + : Thread(prioritySetter, name, std::make_tuple(std::forward(args)...)) {} ~Thread() { if (paused) { diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp index bee8896fa3..73c274e4fc 100644 --- a/platform/glfw/glfw_view.hpp +++ b/platform/glfw/glfw_view.hpp @@ -10,6 +10,8 @@ #include #endif +#include + struct GLFWwindow; class GLFWBackend; class GLFWRendererFrontend; @@ -40,17 +42,11 @@ public: // The expected action is to set a new style, different to the current one. void setChangeStyleCallback(std::function callback); - void setPauseResumeCallback(std::function callback) { - pauseResumeCallback = callback; - }; + void setPauseResumeCallback(std::function callback) { pauseResumeCallback = std::move(callback); }; - void setOnlineStatusCallback(std::function callback) { - onlineStatusCallback = callback; - } + void setOnlineStatusCallback(std::function callback) { onlineStatusCallback = std::move(callback); } - void setResetCacheCallback(std::function callback) { - resetDatabaseCallback = callback; - }; + void setResetCacheCallback(std::function callback) { resetDatabaseCallback = std::move(callback); }; void setShouldClose(); diff --git a/src/mbgl/style/properties.hpp b/src/mbgl/style/properties.hpp index 39b6672734..f8c247f79f 100644 --- a/src/mbgl/style/properties.hpp +++ b/src/mbgl/style/properties.hpp @@ -26,10 +26,7 @@ public: : value(std::move(value_)) { } - Transitioning(Value value_, - Transitioning prior_, - TransitionOptions transition, - TimePoint now) + Transitioning(Value value_, Transitioning prior_, const TransitionOptions& transition, TimePoint now) : begin(now + transition.delay.value_or(Duration::zero())), end(begin + transition.duration.value_or(Duration::zero())), value(std::move(value_)) { diff --git a/src/mbgl/tile/tile_loader_impl.hpp b/src/mbgl/tile/tile_loader_impl.hpp index 51efbb99e9..b12b5c73fb 100644 --- a/src/mbgl/tile/tile_loader_impl.hpp +++ b/src/mbgl/tile/tile_loader_impl.hpp @@ -67,7 +67,7 @@ void TileLoader::loadFromCache() { } resource.loadingMethod = Resource::LoadingMethod::CacheOnly; - request = fileSource->request(resource, [this](Response res) { + request = fileSource->request(resource, [this](const Response& res) { request.reset(); tile.setTriedCache(); @@ -137,7 +137,7 @@ void TileLoader::loadFromNetwork() { // Instead of using Resource::LoadingMethod::All, we're first doing a CacheOnly, and then a // NetworkOnly request. resource.loadingMethod = Resource::LoadingMethod::NetworkOnly; - request = fileSource->request(resource, [this](Response res) { loadedData(res); }); + request = fileSource->request(resource, [this](const Response& res) { loadedData(res); }); } } // namespace mbgl -- cgit v1.2.1