[core] Fix performance-unnecessary-value-param errors in header files

As reported by clang-tidy-8.
This commit is contained in:
Thiago Marcos P. Santos
2020-03-27 18:30:35 +02:00
parent 563d4b6cac
commit 46fa691596
11 changed files with 38 additions and 60 deletions

View File

@@ -90,7 +90,7 @@ protected:
template <typename TaskFn, typename ReplyFn>
void scheduleAndReplyValue(const TaskFn& task,
const ReplyFn& reply,
mapbox::base::WeakPtr<Scheduler> replyScheduler) {
const mapbox::base::WeakPtr<Scheduler>& replyScheduler) {
auto scheduled = [replyScheduler, task, reply] {
auto lock = replyScheduler.lock();
if (!replyScheduler) return;

View File

@@ -5,6 +5,7 @@
#include <mbgl/style/conversion.hpp>
#include <memory>
#include <utility>
#include <vector>
namespace mbgl {
@@ -16,8 +17,7 @@ public:
using Branch = std::pair<std::unique_ptr<Expression>, std::unique_ptr<Expression>>;
Case(type::Type type_, std::vector<Branch> branches_, std::unique_ptr<Expression> 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);

View File

@@ -49,11 +49,8 @@ private:
class Var : public Expression {
public:
Var(std::string name_, std::shared_ptr<Expression> value_) :
Expression(Kind::Var, value_->getType()),
name(std::move(name_)),
value(value_)
{}
Var(std::string name_, const std::shared_ptr<Expression>& value_)
: Expression(Kind::Var, value_->getType()), name(std::move(name_)), value(value_) {}
static ParseResult parse(const mbgl::style::conversion::Convertible&, ParsingContext&);

View File

@@ -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> 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> value_) : Expression(Kind::Literal, type_), value(value_) {}
EvaluationResult evaluate(const EvaluationContext&) const override {
return value;

View File

@@ -15,15 +15,14 @@ class Match : public Expression {
public:
using Branches = std::unordered_map<T, std::shared_ptr<Expression>>;
Match(type::Type type_,
Match(const type::Type& type_,
std::unique_ptr<Expression> input_,
Branches branches_,
std::unique_ptr<Expression> otherwise_
) : Expression(Kind::Match, type_),
input(std::move(input_)),
branches(std::move(branches_)),
otherwise(std::move(otherwise_))
{}
std::unique_ptr<Expression> otherwise_)
: Expression(Kind::Match, type_),
input(std::move(input_)),
branches(std::move(branches_)),
otherwise(std::move(otherwise_)) {}
EvaluationResult evaluate(const EvaluationContext& params) const override;

View File

@@ -7,10 +7,11 @@
#include <iterator>
#include <map>
#include <unordered_map>
#include <string>
#include <vector>
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
namespace mbgl {
namespace style {
@@ -122,22 +123,21 @@ public:
Check whether `t` is a subtype of `expected`, collecting an error if not.
*/
optional<std::string> checkType(const type::Type& t);
optional<std::shared_ptr<Expression>> getBinding(const std::string name) {
optional<std::shared_ptr<Expression>> getBinding(const std::string& name) {
if (!scope) return optional<std::shared_ptr<Expression>>();
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) {

View File

@@ -40,14 +40,9 @@ public:
float pixelRatio,
ImageStretches stretchX = {},
ImageStretches stretchY = {},
optional<ImageContent> content = nullopt)
: Image(std::move(id),
std::move(image),
pixelRatio,
false,
std::move(stretchX),
std::move(stretchY),
content) {}
const optional<ImageContent>& 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;

View File

@@ -77,8 +77,8 @@ public:
: Thread([] { platform::makeThreadLowPriority(); }, name, std::make_tuple(std::forward<Args>(args)...)) {}
template <typename... Args>
Thread(std::function<void()> prioritySetter, const std::string& name, Args&&... args)
: Thread(std::move(prioritySetter), name, std::make_tuple(std::forward<Args>(args)...)) {}
Thread(const std::function<void()>& prioritySetter, const std::string& name, Args&&... args)
: Thread(prioritySetter, name, std::make_tuple(std::forward<Args>(args)...)) {}
~Thread() {
if (paused) {

View File

@@ -10,6 +10,8 @@
#include <mbgl/style/layers/location_indicator_layer.hpp>
#endif
#include <utility>
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<void()> callback);
void setPauseResumeCallback(std::function<void()> callback) {
pauseResumeCallback = callback;
};
void setPauseResumeCallback(std::function<void()> callback) { pauseResumeCallback = std::move(callback); };
void setOnlineStatusCallback(std::function<void()> callback) {
onlineStatusCallback = callback;
}
void setOnlineStatusCallback(std::function<void()> callback) { onlineStatusCallback = std::move(callback); }
void setResetCacheCallback(std::function<void()> callback) {
resetDatabaseCallback = callback;
};
void setResetCacheCallback(std::function<void()> callback) { resetDatabaseCallback = std::move(callback); };
void setShouldClose();

View File

@@ -26,10 +26,7 @@ public:
: value(std::move(value_)) {
}
Transitioning(Value value_,
Transitioning<Value> prior_,
TransitionOptions transition,
TimePoint now)
Transitioning(Value value_, Transitioning<Value> 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_)) {

View File

@@ -67,7 +67,7 @@ void TileLoader<T>::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<T>::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