diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-06-12 13:53:35 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-06-13 23:32:05 +0300 |
commit | 4161d197fdb59587b3ef5deac321605fc911a2ab (patch) | |
tree | 0bf4fa48a4e42fac0afce07f099ebace3ff5a698 | |
parent | 92f605df326ac4b1f4dd65928d6350b97eea6096 (diff) | |
download | qtlocation-mapboxgl-4161d197fdb59587b3ef5deac321605fc911a2ab.tar.gz |
[tidy] Check modernize-pass-by-value
Ref: http://clang.llvm.org/extra/clang-tidy/checks/modernize-pass-by-value.html
54 files changed, 120 insertions, 135 deletions
diff --git a/include/mbgl/storage/offline.hpp b/include/mbgl/storage/offline.hpp index 990c8470bb..bbd8674e5a 100644 --- a/include/mbgl/storage/offline.hpp +++ b/include/mbgl/storage/offline.hpp @@ -27,7 +27,7 @@ class Tileset; */ class OfflineTilePyramidRegionDefinition { public: - OfflineTilePyramidRegionDefinition(const std::string&, const LatLngBounds&, double, double, float); + OfflineTilePyramidRegionDefinition(std::string, LatLngBounds, double, double, float); /* Private */ std::vector<CanonicalTileID> tileCover(SourceType, uint16_t tileSize, const Tileset&) const; @@ -200,8 +200,8 @@ private: friend class OfflineDatabase; OfflineRegion(int64_t id, - const OfflineRegionDefinition&, - const OfflineRegionMetadata&); + OfflineRegionDefinition, + OfflineRegionMetadata); const int64_t id; const OfflineRegionDefinition definition; diff --git a/include/mbgl/storage/resource.hpp b/include/mbgl/storage/resource.hpp index a75de380a1..31df069952 100644 --- a/include/mbgl/storage/resource.hpp +++ b/include/mbgl/storage/resource.hpp @@ -33,10 +33,10 @@ public: Required = true, }; - Resource(Kind kind_, const std::string& url_, optional<TileData> tileData_ = {}, Necessity necessity_ = Required) + Resource(Kind kind_, std::string url_, optional<TileData> tileData_ = {}, Necessity necessity_ = Required) : kind(kind_), necessity(necessity_), - url(url_), + url(std::move(url_)), tileData(std::move(tileData_)) { } diff --git a/include/mbgl/storage/response.hpp b/include/mbgl/storage/response.hpp index 83227573cf..6c79f5e181 100644 --- a/include/mbgl/storage/response.hpp +++ b/include/mbgl/storage/response.hpp @@ -49,7 +49,7 @@ public: std::string message; public: - Error(Reason, const std::string& = ""); + Error(Reason, std::string = ""); }; std::ostream& operator<<(std::ostream&, Response::Error::Reason); diff --git a/include/mbgl/style/function.hpp b/include/mbgl/style/function.hpp index da2659c76a..44ffa31079 100644 --- a/include/mbgl/style/function.hpp +++ b/include/mbgl/style/function.hpp @@ -12,8 +12,8 @@ public: using Stop = std::pair<float, T>; using Stops = std::vector<Stop>; - explicit Function(const Stops& stops_, float base_) - : base(base_), stops(stops_) {} + explicit Function(Stops stops_, float base_) + : base(base_), stops(std::move(stops_)) {} float getBase() const { return base; } const std::vector<std::pair<float, T>>& getStops() const { return stops; } diff --git a/include/mbgl/style/transition_options.hpp b/include/mbgl/style/transition_options.hpp index 87faff21f8..5803fe05c9 100644 --- a/include/mbgl/style/transition_options.hpp +++ b/include/mbgl/style/transition_options.hpp @@ -8,8 +8,8 @@ namespace style { class TransitionOptions { public: - TransitionOptions(const optional<Duration>& duration_ = {}, const optional<Duration>& delay_ = {}) - : duration(duration_), delay(delay_) {} + TransitionOptions(optional<Duration> duration_ = {}, optional<Duration> delay_ = {}) + : duration(std::move(duration_)), delay(std::move(delay_)) {} optional<Duration> duration; optional<Duration> delay; diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp index 5db307e482..4af8906465 100644 --- a/include/mbgl/util/geo.hpp +++ b/include/mbgl/util/geo.hpp @@ -161,8 +161,8 @@ private: LatLng sw; LatLng ne; - LatLngBounds(const LatLng& sw_, const LatLng& ne_) - : sw(sw_), ne(ne_) {} + LatLngBounds(LatLng sw_, LatLng ne_) + : sw(std::move(sw_)), ne(std::move(ne_)) {} friend bool operator==(const LatLngBounds&, const LatLngBounds&); friend bool operator!=(const LatLngBounds&, const LatLngBounds&); diff --git a/platform/default/asset_file_source.cpp b/platform/default/asset_file_source.cpp index 3a47f349fe..c2694ba469 100644 --- a/platform/default/asset_file_source.cpp +++ b/platform/default/asset_file_source.cpp @@ -14,8 +14,8 @@ namespace mbgl { class AssetFileSource::Impl { public: - Impl(const std::string& root_) - : root(root_) { + Impl(std::string root_) + : root(std::move(root_)) { } void request(const std::string& url, FileSource::Callback callback) { diff --git a/platform/default/mbgl/storage/offline.cpp b/platform/default/mbgl/storage/offline.cpp index d8e0357ae2..812e427157 100644 --- a/platform/default/mbgl/storage/offline.cpp +++ b/platform/default/mbgl/storage/offline.cpp @@ -11,9 +11,9 @@ namespace mbgl { OfflineTilePyramidRegionDefinition::OfflineTilePyramidRegionDefinition( - const std::string& styleURL_, const LatLngBounds& bounds_, double minZoom_, double maxZoom_, float pixelRatio_) - : styleURL(styleURL_), - bounds(bounds_), + std::string styleURL_, LatLngBounds bounds_, double minZoom_, double maxZoom_, float pixelRatio_) + : styleURL(std::move(styleURL_)), + bounds(std::move(bounds_)), minZoom(minZoom_), maxZoom(maxZoom_), pixelRatio(pixelRatio_) { @@ -97,11 +97,11 @@ std::string encodeOfflineRegionDefinition(const OfflineRegionDefinition& region) } OfflineRegion::OfflineRegion(int64_t id_, - const OfflineRegionDefinition& definition_, - const OfflineRegionMetadata& metadata_) + OfflineRegionDefinition definition_, + OfflineRegionMetadata metadata_) : id(id_), - definition(definition_), - metadata(metadata_) { + definition(std::move(definition_)), + metadata(std::move(metadata_)) { } OfflineRegion::OfflineRegion(OfflineRegion&&) = default; diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp index 3193909294..e46fc42225 100644 --- a/platform/default/mbgl/storage/offline_database.cpp +++ b/platform/default/mbgl/storage/offline_database.cpp @@ -18,8 +18,8 @@ OfflineDatabase::Statement::~Statement() { stmt.clearBindings(); } -OfflineDatabase::OfflineDatabase(const std::string& path_, uint64_t maximumCacheSize_) - : path(path_), +OfflineDatabase::OfflineDatabase(std::string path_, uint64_t maximumCacheSize_) + : path(std::move(path_)), maximumCacheSize(maximumCacheSize_) { ensureSchema(); } diff --git a/platform/default/mbgl/storage/offline_database.hpp b/platform/default/mbgl/storage/offline_database.hpp index 3f5df3509b..55cb7ad2fa 100644 --- a/platform/default/mbgl/storage/offline_database.hpp +++ b/platform/default/mbgl/storage/offline_database.hpp @@ -27,8 +27,7 @@ class OfflineDatabase : private util::noncopyable { public: // Limits affect ambient caching (put) only; resources required by offline // regions are exempt. - OfflineDatabase(const std::string& path, - uint64_t maximumCacheSize = util::DEFAULT_MAX_CACHE_SIZE); + OfflineDatabase(std::string path, uint64_t maximumCacheSize = util::DEFAULT_MAX_CACHE_SIZE); ~OfflineDatabase(); optional<Response> get(const Resource&); diff --git a/platform/default/online_file_source.cpp b/platform/default/online_file_source.cpp index a4ac2c2b2b..e0adfd8a54 100644 --- a/platform/default/online_file_source.cpp +++ b/platform/default/online_file_source.cpp @@ -26,7 +26,7 @@ class OnlineFileRequest : public AsyncRequest { public: using Callback = std::function<void (Response)>; - OnlineFileRequest(const Resource&, Callback, OnlineFileSource::Impl&); + OnlineFileRequest(Resource, Callback, OnlineFileSource::Impl&); ~OnlineFileRequest(); void networkIsReachableAgain(); @@ -182,9 +182,9 @@ std::unique_ptr<AsyncRequest> OnlineFileSource::request(const Resource& resource return std::make_unique<OnlineFileRequest>(res, callback, *impl); } -OnlineFileRequest::OnlineFileRequest(const Resource& resource_, Callback callback_, OnlineFileSource::Impl& impl_) +OnlineFileRequest::OnlineFileRequest(Resource resource_, Callback callback_, OnlineFileSource::Impl& impl_) : impl(impl_), - resource(resource_), + resource(std::move(resource_)), callback(std::move(callback_)) { impl.add(this); diff --git a/src/mbgl/annotation/annotation_tile.cpp b/src/mbgl/annotation/annotation_tile.cpp index 92234f5000..79e281acce 100644 --- a/src/mbgl/annotation/annotation_tile.cpp +++ b/src/mbgl/annotation/annotation_tile.cpp @@ -36,8 +36,8 @@ optional<Value> AnnotationTileFeature::getValue(const std::string& key) const { return optional<Value>(); } -AnnotationTileLayer::AnnotationTileLayer(const std::string &name_) - : name(name_) {} +AnnotationTileLayer::AnnotationTileLayer(std::string name_) + : name(std::move(name_)) {} util::ptr<GeometryTileLayer> AnnotationTileData::getLayer(const std::string& name) const { auto it = layers.find(name); diff --git a/src/mbgl/annotation/annotation_tile.hpp b/src/mbgl/annotation/annotation_tile.hpp index 26a0d36f91..bfe83ff557 100644 --- a/src/mbgl/annotation/annotation_tile.hpp +++ b/src/mbgl/annotation/annotation_tile.hpp @@ -40,7 +40,7 @@ public: class AnnotationTileLayer : public GeometryTileLayer { public: - AnnotationTileLayer(const std::string&); + AnnotationTileLayer(std::string); std::size_t featureCount() const override { return features.size(); } util::ptr<const GeometryTileFeature> getFeature(std::size_t i) const override { return features[i]; } diff --git a/src/mbgl/annotation/fill_annotation_impl.cpp b/src/mbgl/annotation/fill_annotation_impl.cpp index 31c9f6d720..cbd76ede97 100644 --- a/src/mbgl/annotation/fill_annotation_impl.cpp +++ b/src/mbgl/annotation/fill_annotation_impl.cpp @@ -7,9 +7,9 @@ namespace mbgl { using namespace style; -FillAnnotationImpl::FillAnnotationImpl(const AnnotationID id_, const FillAnnotation& annotation_, const uint8_t maxZoom_) +FillAnnotationImpl::FillAnnotationImpl(AnnotationID id_, FillAnnotation annotation_, uint8_t maxZoom_) : ShapeAnnotationImpl(id_, maxZoom_), - annotation(annotation_) { + annotation(std::move(annotation_)) { } void FillAnnotationImpl::updateStyle(Style& style) const { diff --git a/src/mbgl/annotation/fill_annotation_impl.hpp b/src/mbgl/annotation/fill_annotation_impl.hpp index b879860c08..6376eee880 100644 --- a/src/mbgl/annotation/fill_annotation_impl.hpp +++ b/src/mbgl/annotation/fill_annotation_impl.hpp @@ -7,7 +7,7 @@ namespace mbgl { class FillAnnotationImpl : public ShapeAnnotationImpl { public: - FillAnnotationImpl(const AnnotationID, const FillAnnotation&, const uint8_t maxZoom); + FillAnnotationImpl(AnnotationID, FillAnnotation, uint8_t maxZoom); void updateStyle(style::Style&) const final; const ShapeAnnotationGeometry& geometry() const final; diff --git a/src/mbgl/annotation/line_annotation_impl.cpp b/src/mbgl/annotation/line_annotation_impl.cpp index 85177591f4..e689c3240d 100644 --- a/src/mbgl/annotation/line_annotation_impl.cpp +++ b/src/mbgl/annotation/line_annotation_impl.cpp @@ -7,9 +7,9 @@ namespace mbgl { using namespace style; -LineAnnotationImpl::LineAnnotationImpl(const AnnotationID id_, const LineAnnotation& annotation_, const uint8_t maxZoom_) +LineAnnotationImpl::LineAnnotationImpl(AnnotationID id_, LineAnnotation annotation_, uint8_t maxZoom_) : ShapeAnnotationImpl(id_, maxZoom_), - annotation(annotation_) { + annotation(std::move(annotation_)) { } void LineAnnotationImpl::updateStyle(Style& style) const { diff --git a/src/mbgl/annotation/line_annotation_impl.hpp b/src/mbgl/annotation/line_annotation_impl.hpp index c9a37dd390..7945da5d97 100644 --- a/src/mbgl/annotation/line_annotation_impl.hpp +++ b/src/mbgl/annotation/line_annotation_impl.hpp @@ -7,7 +7,7 @@ namespace mbgl { class LineAnnotationImpl : public ShapeAnnotationImpl { public: - LineAnnotationImpl(const AnnotationID, const LineAnnotation&, const uint8_t maxZoom); + LineAnnotationImpl(AnnotationID, LineAnnotation, uint8_t maxZoom); void updateStyle(style::Style&) const final; const ShapeAnnotationGeometry& geometry() const final; diff --git a/src/mbgl/annotation/style_sourced_annotation_impl.cpp b/src/mbgl/annotation/style_sourced_annotation_impl.cpp index 43a27c8aac..d828014606 100644 --- a/src/mbgl/annotation/style_sourced_annotation_impl.cpp +++ b/src/mbgl/annotation/style_sourced_annotation_impl.cpp @@ -9,9 +9,9 @@ namespace mbgl { using namespace style; -StyleSourcedAnnotationImpl::StyleSourcedAnnotationImpl(const AnnotationID id_, const StyleSourcedAnnotation& annotation_, const uint8_t maxZoom_) +StyleSourcedAnnotationImpl::StyleSourcedAnnotationImpl(AnnotationID id_, StyleSourcedAnnotation annotation_, uint8_t maxZoom_) : ShapeAnnotationImpl(id_, maxZoom_), - annotation(annotation_) { + annotation(std::move(annotation_)) { } void StyleSourcedAnnotationImpl::updateStyle(Style& style) const { diff --git a/src/mbgl/annotation/style_sourced_annotation_impl.hpp b/src/mbgl/annotation/style_sourced_annotation_impl.hpp index 09ef474fc0..82b947302d 100644 --- a/src/mbgl/annotation/style_sourced_annotation_impl.hpp +++ b/src/mbgl/annotation/style_sourced_annotation_impl.hpp @@ -7,7 +7,7 @@ namespace mbgl { class StyleSourcedAnnotationImpl : public ShapeAnnotationImpl { public: - StyleSourcedAnnotationImpl(const AnnotationID, const StyleSourcedAnnotation&, const uint8_t maxZoom); + StyleSourcedAnnotationImpl(AnnotationID, StyleSourcedAnnotation, uint8_t maxZoom); void updateStyle(style::Style&) const final; const ShapeAnnotationGeometry& geometry() const final; diff --git a/src/mbgl/annotation/symbol_annotation_impl.cpp b/src/mbgl/annotation/symbol_annotation_impl.cpp index 9859f6b032..5ac2581949 100644 --- a/src/mbgl/annotation/symbol_annotation_impl.cpp +++ b/src/mbgl/annotation/symbol_annotation_impl.cpp @@ -5,9 +5,9 @@ namespace mbgl { -SymbolAnnotationImpl::SymbolAnnotationImpl(const AnnotationID id_, const SymbolAnnotation& annotation_) +SymbolAnnotationImpl::SymbolAnnotationImpl(AnnotationID id_, SymbolAnnotation annotation_) : id(id_), - annotation(annotation_) { + annotation(std::move(annotation_)) { } void SymbolAnnotationImpl::updateLayer(const CanonicalTileID& tileID, AnnotationTileLayer& layer) const { diff --git a/src/mbgl/annotation/symbol_annotation_impl.hpp b/src/mbgl/annotation/symbol_annotation_impl.hpp index 5dc882ab93..48ab321500 100644 --- a/src/mbgl/annotation/symbol_annotation_impl.hpp +++ b/src/mbgl/annotation/symbol_annotation_impl.hpp @@ -37,7 +37,7 @@ class CanonicalTileID; class SymbolAnnotationImpl { public: - SymbolAnnotationImpl(const AnnotationID, const SymbolAnnotation&); + SymbolAnnotationImpl(AnnotationID, SymbolAnnotation); void updateLayer(const CanonicalTileID&, AnnotationTileLayer&) const; diff --git a/src/mbgl/geometry/glyph_atlas.hpp b/src/mbgl/geometry/glyph_atlas.hpp index d3e2a62199..b1fc9d5747 100644 --- a/src/mbgl/geometry/glyph_atlas.hpp +++ b/src/mbgl/geometry/glyph_atlas.hpp @@ -39,8 +39,8 @@ public: private: struct GlyphValue { - GlyphValue(const Rect<uint16_t>& rect_, uintptr_t id) - : rect(rect_), ids({ id }) {} + GlyphValue(Rect<uint16_t> rect_, uintptr_t id) + : rect(std::move(rect_)), ids({ id }) {} Rect<uint16_t> rect; std::set<uintptr_t> ids; }; diff --git a/src/mbgl/renderer/render_tile.hpp b/src/mbgl/renderer/render_tile.hpp index cb18504c8e..55a605280e 100644 --- a/src/mbgl/renderer/render_tile.hpp +++ b/src/mbgl/renderer/render_tile.hpp @@ -11,9 +11,7 @@ class Tile; class RenderTile { public: - RenderTile(const UnwrappedTileID& id_, Tile& tile_) : id(id_), tile(tile_) { - } - + RenderTile(UnwrappedTileID id_, Tile& tile_) : id(std::move(id_)), tile(tile_) {} RenderTile(const RenderTile&) = delete; RenderTile(RenderTile&&) = default; RenderTile& operator=(const RenderTile&) = delete; diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index e12522cb48..60624fa59e 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -60,14 +60,14 @@ SymbolInstance::SymbolInstance(Anchor& anchor, const GeometryCoordinates& line, {} -SymbolBucket::SymbolBucket(uint32_t overscaling_, float zoom_, const MapMode mode_, const std::string& bucketName_, const std::string& sourceLayerName_) +SymbolBucket::SymbolBucket(uint32_t overscaling_, float zoom_, const MapMode mode_, std::string bucketName_, std::string sourceLayerName_) : overscaling(overscaling_), zoom(zoom_), tileSize(util::tileSize * overscaling_), tilePixelRatio(float(util::EXTENT) / tileSize), mode(mode_), - bucketName(bucketName_), - sourceLayerName(sourceLayerName_) {} + bucketName(std::move(bucketName_)), + sourceLayerName(std::move(sourceLayerName_)) {} SymbolBucket::~SymbolBucket() { // Do not remove. header file only contains forward definitions to unique pointers. diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp index 47f3c52572..98b8116c26 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -66,7 +66,7 @@ class SymbolBucket : public Bucket { typedef ElementGroup<1> CollisionBoxElementGroup; public: - SymbolBucket(uint32_t overscaling, float zoom, const MapMode, const std::string& bucketName_, const std::string& sourceLayerName_); + SymbolBucket(uint32_t overscaling, float zoom, const MapMode, std::string bucketName_, std::string sourceLayerName_); ~SymbolBucket() override; void upload(gl::ObjectStore&) override; diff --git a/src/mbgl/sprite/sprite_atlas.cpp b/src/mbgl/sprite/sprite_atlas.cpp index df821a990a..2e1616669f 100644 --- a/src/mbgl/sprite/sprite_atlas.cpp +++ b/src/mbgl/sprite/sprite_atlas.cpp @@ -247,9 +247,8 @@ void SpriteAtlas::bind(bool linear, gl::ObjectStore& objectStore) { SpriteAtlas::~SpriteAtlas() = default; -SpriteAtlas::Holder::Holder(const std::shared_ptr<const SpriteImage>& spriteImage_, - const Rect<dimension>& pos_) - : spriteImage(spriteImage_), pos(pos_) { +SpriteAtlas::Holder::Holder(std::shared_ptr<const SpriteImage> spriteImage_, Rect<dimension> pos_) + : spriteImage(std::move(spriteImage_)), pos(std::move(pos_)) { } SpriteAtlas::Holder::Holder(Holder&& h) : spriteImage(std::move(h.spriteImage)), pos(h.pos) { diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp index 3d91f5c9d8..000b7e8132 100644 --- a/src/mbgl/sprite/sprite_atlas.hpp +++ b/src/mbgl/sprite/sprite_atlas.hpp @@ -75,7 +75,7 @@ private: const float pixelRatio; struct Holder : private util::noncopyable { - inline Holder(const std::shared_ptr<const SpriteImage>&, const Rect<dimension>&); + inline Holder(std::shared_ptr<const SpriteImage>, Rect<dimension>); inline Holder(Holder&&); std::shared_ptr<const SpriteImage> spriteImage; const Rect<dimension> pos; diff --git a/src/mbgl/storage/response.cpp b/src/mbgl/storage/response.cpp index 644d73d286..aa55d458c2 100644 --- a/src/mbgl/storage/response.cpp +++ b/src/mbgl/storage/response.cpp @@ -21,8 +21,8 @@ Response& Response::operator=(const Response& res) { return *this; } -Response::Error::Error(Reason reason_, const std::string& message_) - : reason(reason_), message(message_) { +Response::Error::Error(Reason reason_, std::string message_) + : reason(reason_), message(std::move(message_)) { } std::ostream& operator<<(std::ostream& os, Response::Error::Reason r) { diff --git a/src/mbgl/style/calculation_parameters.hpp b/src/mbgl/style/calculation_parameters.hpp index 2afd7c4b34..e1f059c524 100644 --- a/src/mbgl/style/calculation_parameters.hpp +++ b/src/mbgl/style/calculation_parameters.hpp @@ -12,13 +12,13 @@ public: : z(z_) {} CalculationParameters(float z_, - const TimePoint& now_, - const ZoomHistory& zoomHistory_, - const Duration& defaultFadeDuration_) + TimePoint now_, + ZoomHistory zoomHistory_, + Duration defaultFadeDuration_) : z(z_), - now(now_), - zoomHistory(zoomHistory_), - defaultFadeDuration(defaultFadeDuration_) {} + now(std::move(now_)), + zoomHistory(std::move(zoomHistory_)), + defaultFadeDuration(std::move(defaultFadeDuration_)) {} float z; TimePoint now; diff --git a/src/mbgl/style/layers/background_layer_properties.cpp b/src/mbgl/style/layers/background_layer_properties.cpp index a20cedf12c..f4c9b952b0 100644 --- a/src/mbgl/style/layers/background_layer_properties.cpp +++ b/src/mbgl/style/layers/background_layer_properties.cpp @@ -1,6 +1,7 @@ // This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`. #include <mbgl/style/layers/background_layer_properties.hpp> +#include <utility> namespace mbgl { namespace style { diff --git a/src/mbgl/style/layers/circle_layer_properties.cpp b/src/mbgl/style/layers/circle_layer_properties.cpp index b21df1e2d0..fed6d5cddc 100644 --- a/src/mbgl/style/layers/circle_layer_properties.cpp +++ b/src/mbgl/style/layers/circle_layer_properties.cpp @@ -1,6 +1,7 @@ // This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`. #include <mbgl/style/layers/circle_layer_properties.hpp> +#include <utility> namespace mbgl { namespace style { diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp index 62fd59684e..7cb75781a3 100644 --- a/src/mbgl/style/paint_property.hpp +++ b/src/mbgl/style/paint_property.hpp @@ -118,8 +118,8 @@ private: TimePoint end_, PropertyValue<T> value_) : prior(std::move(prior_)), - begin(begin_), - end(end_), + begin(std::move(begin_)), + end(std::move(end_)), value(std::move(value_)) { } diff --git a/src/mbgl/style/property_evaluator.hpp b/src/mbgl/style/property_evaluator.hpp index 0d23a44c05..a0bce2f499 100644 --- a/src/mbgl/style/property_evaluator.hpp +++ b/src/mbgl/style/property_evaluator.hpp @@ -13,9 +13,9 @@ class PropertyEvaluator { public: using ResultType = T; - PropertyEvaluator(const CalculationParameters& parameters_, const T& defaultValue_) + PropertyEvaluator(const CalculationParameters& parameters_, T defaultValue_) : parameters(parameters_), - defaultValue(defaultValue_) {} + defaultValue(std::move(defaultValue_)) {} T operator()(const Undefined&) const { return defaultValue; } T operator()(const T& constant) const { return constant; } @@ -40,9 +40,9 @@ class CrossFadedPropertyEvaluator { public: using ResultType = Faded<T>; - CrossFadedPropertyEvaluator(const CalculationParameters& parameters_, const T& defaultValue_) + CrossFadedPropertyEvaluator(const CalculationParameters& parameters_, T defaultValue_) : parameters(parameters_), - defaultValue(defaultValue_) {} + defaultValue(std::move(defaultValue_)) {} Faded<T> operator()(const Undefined&) const; Faded<T> operator()(const T& constant) const; diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp index cd87eb6587..544d230a25 100644 --- a/src/mbgl/style/source.cpp +++ b/src/mbgl/style/source.cpp @@ -43,14 +43,14 @@ namespace style { static SourceObserver nullObserver; Source::Source(SourceType type_, - const std::string& id_, - const std::string& url_, + std::string id_, + std::string url_, uint16_t tileSize_, std::unique_ptr<Tileset>&& tileset_, std::unique_ptr<mapbox::geojsonvt::GeoJSONVT>&& geojsonvt_) : type(type_), - id(id_), - url(url_), + id(std::move(id_)), + url(std::move(url_)), tileSize(tileSize_), tileset(std::move(tileset_)), geojsonvt(std::move(geojsonvt_)), diff --git a/src/mbgl/style/source.hpp b/src/mbgl/style/source.hpp index 453f52a8bf..c17806631b 100644 --- a/src/mbgl/style/source.hpp +++ b/src/mbgl/style/source.hpp @@ -41,8 +41,8 @@ class SourceObserver; class Source : public TileObserver, private util::noncopyable { public: Source(SourceType, - const std::string& id, - const std::string& url, + std::string id, + std::string url, uint16_t tileSize, std::unique_ptr<Tileset>&&, std::unique_ptr<mapbox::geojsonvt::GeoJSONVT>&&); diff --git a/src/mbgl/style/update_parameters.hpp b/src/mbgl/style/update_parameters.hpp index 9faaa32d6f..0dad7361e1 100644 --- a/src/mbgl/style/update_parameters.hpp +++ b/src/mbgl/style/update_parameters.hpp @@ -29,7 +29,7 @@ public: Style& style_) : pixelRatio(pixelRatio_), debugOptions(debugOptions_), - animationTime(animationTime_), + animationTime(std::move(animationTime_)), transformState(transformState_), worker(worker_), fileSource(fileSource_), diff --git a/src/mbgl/text/collision_feature.cpp b/src/mbgl/text/collision_feature.cpp index 57a9da0440..74a41099ff 100644 --- a/src/mbgl/text/collision_feature.cpp +++ b/src/mbgl/text/collision_feature.cpp @@ -5,9 +5,9 @@ namespace mbgl { CollisionFeature::CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const float top, const float bottom, const float left, const float right, - const float boxScale, const float padding, const bool alongLine, const IndexedSubfeature& indexedFeature_, + const float boxScale, const float padding, const bool alongLine, IndexedSubfeature indexedFeature_, const bool straight) - : indexedFeature(indexedFeature_) { + : indexedFeature(std::move(indexedFeature_)) { if (top == 0 && bottom == 0 && left == 0 && right == 0) return; diff --git a/src/mbgl/text/collision_feature.hpp b/src/mbgl/text/collision_feature.hpp index 204da8f2e6..f0bb0f7340 100644 --- a/src/mbgl/text/collision_feature.hpp +++ b/src/mbgl/text/collision_feature.hpp @@ -10,8 +10,8 @@ namespace mbgl { class CollisionBox { public: - explicit CollisionBox(const Point<float> &_anchor, float _x1, float _y1, float _x2, float _y2, float _maxScale) : - anchor(_anchor), x1(_x1), y1(_y1), x2(_x2), y2(_y2), maxScale(_maxScale) {} + explicit CollisionBox(Point<float> _anchor, float _x1, float _y1, float _x2, float _y2, float _maxScale) : + anchor(std::move(_anchor)), x1(_x1), y1(_y1), x2(_x2), y2(_y2), maxScale(_maxScale) {} // the box is centered around the anchor point Point<float> anchor; @@ -51,7 +51,7 @@ namespace mbgl { explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const float top, const float bottom, const float left, const float right, const float boxScale, const float padding, const bool alongLine, - const IndexedSubfeature&, const bool straight); + IndexedSubfeature, const bool straight); std::vector<CollisionBox> boxes; diff --git a/src/mbgl/text/collision_tile.cpp b/src/mbgl/text/collision_tile.cpp index e7824cde3c..982dff1688 100644 --- a/src/mbgl/text/collision_tile.cpp +++ b/src/mbgl/text/collision_tile.cpp @@ -9,7 +9,7 @@ namespace mbgl { auto infinity = std::numeric_limits<float>::infinity(); -CollisionTile::CollisionTile(PlacementConfig config_) : config(config_), +CollisionTile::CollisionTile(PlacementConfig config_) : config(std::move(config_)), edges({{ // left CollisionBox(Point<float>(0, 0), 0, -infinity, 0, infinity, infinity), diff --git a/src/mbgl/text/glyph.hpp b/src/mbgl/text/glyph.hpp index b5891831d5..ce07b1b3fd 100644 --- a/src/mbgl/text/glyph.hpp +++ b/src/mbgl/text/glyph.hpp @@ -29,9 +29,8 @@ struct GlyphMetrics { struct Glyph { inline explicit Glyph() : rect(0, 0, 0, 0), metrics() {} - inline explicit Glyph(const Rect<uint16_t> &rect_, - const GlyphMetrics &metrics_) - : rect(rect_), metrics(metrics_) {} + inline explicit Glyph(Rect<uint16_t> rect_, GlyphMetrics metrics_) + : rect(std::move(rect_)), metrics(std::move(metrics_)) {} operator bool() const { return metrics || rect.hasArea(); diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 1c94cb811e..a46b329d1a 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -62,10 +62,10 @@ SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon, } struct GlyphInstance { - explicit GlyphInstance(const Point<float> &anchorPoint_) : anchorPoint(anchorPoint_) {} - explicit GlyphInstance(const Point<float> &anchorPoint_, float offset_, float minScale_, float maxScale_, + explicit GlyphInstance(Point<float> anchorPoint_) : anchorPoint(std::move(anchorPoint_)) {} + explicit GlyphInstance(Point<float> anchorPoint_, float offset_, float minScale_, float maxScale_, float angle_) - : anchorPoint(anchorPoint_), offset(offset_), minScale(minScale_), maxScale(maxScale_), angle(angle_) {} + : anchorPoint(std::move(anchorPoint_)), offset(offset_), minScale(minScale_), maxScale(maxScale_), angle(angle_) {} const Point<float> anchorPoint; const float offset = 0.0f; diff --git a/src/mbgl/text/quads.hpp b/src/mbgl/text/quads.hpp index 814e4edb73..0ea5129238 100644 --- a/src/mbgl/text/quads.hpp +++ b/src/mbgl/text/quads.hpp @@ -15,18 +15,17 @@ class SymbolLayoutProperties; } // namespace style struct SymbolQuad { - explicit SymbolQuad(const Point<float> &tl_, const Point<float> &tr_, - const Point<float> &bl_, const Point<float> &br_, - const Rect<uint16_t> &tex_, float anchorAngle_, float glyphAngle_, const Point<float> &anchorPoint_, + explicit SymbolQuad(Point<float> tl_, Point<float> tr_, Point<float> bl_, Point<float> br_, + Rect<uint16_t> tex_, float anchorAngle_, float glyphAngle_, Point<float> anchorPoint_, float minScale_, float maxScale_) - : tl(tl_), - tr(tr_), - bl(bl_), - br(br_), - tex(tex_), + : tl(std::move(tl_)), + tr(std::move(tr_)), + bl(std::move(bl_)), + br(std::move(br_)), + tex(std::move(tex_)), anchorAngle(anchorAngle_), glyphAngle(glyphAngle_), - anchorPoint(anchorPoint_), + anchorPoint(std::move(anchorPoint_)), minScale(minScale_), maxScale(maxScale_) {} diff --git a/src/mbgl/tile/tile.cpp b/src/mbgl/tile/tile.cpp index 846cda26cf..6595c314ee 100644 --- a/src/mbgl/tile/tile.cpp +++ b/src/mbgl/tile/tile.cpp @@ -7,8 +7,7 @@ namespace mbgl { static TileObserver nullObserver; -Tile::Tile(const OverscaledTileID& id_) - : id(id_), observer(&nullObserver) { +Tile::Tile(OverscaledTileID id_) : id(std::move(id_)), observer(&nullObserver) { } Tile::~Tile() = default; diff --git a/src/mbgl/tile/tile.hpp b/src/mbgl/tile/tile.hpp index 78228e431d..931317463a 100644 --- a/src/mbgl/tile/tile.hpp +++ b/src/mbgl/tile/tile.hpp @@ -27,7 +27,7 @@ class Layer; class Tile : private util::noncopyable { public: - Tile(const OverscaledTileID&); + Tile(OverscaledTileID); virtual ~Tile(); void setObserver(TileObserver* observer); diff --git a/src/mbgl/tile/tile_id.hpp b/src/mbgl/tile/tile_id.hpp index f9afdfa529..f561db9a4d 100644 --- a/src/mbgl/tile/tile_id.hpp +++ b/src/mbgl/tile/tile_id.hpp @@ -45,8 +45,7 @@ std::string toString(const CanonicalTileID&); // z/x/y describe the class OverscaledTileID { public: - OverscaledTileID(uint8_t overscaledZ, const CanonicalTileID&); - OverscaledTileID(uint8_t overscaledZ, CanonicalTileID&&); + OverscaledTileID(uint8_t overscaledZ, CanonicalTileID); OverscaledTileID(uint8_t overscaledZ, uint8_t z, uint32_t x, uint32_t y); OverscaledTileID(uint8_t z, uint32_t x, uint32_t y); explicit OverscaledTileID(const CanonicalTileID&); @@ -75,8 +74,7 @@ std::string toString(const OverscaledTileID&); class UnwrappedTileID { public: UnwrappedTileID(uint8_t z, int64_t x, int64_t y); - UnwrappedTileID(int16_t wrap, const CanonicalTileID&); - UnwrappedTileID(int16_t wrap, CanonicalTileID&&); + UnwrappedTileID(int16_t wrap, CanonicalTileID); bool operator==(const UnwrappedTileID&) const; bool operator!=(const UnwrappedTileID&) const; bool operator<(const UnwrappedTileID&) const; @@ -143,13 +141,8 @@ inline std::array<CanonicalTileID, 4> CanonicalTileID::children() const { } }; } -inline OverscaledTileID::OverscaledTileID(uint8_t overscaledZ_, const CanonicalTileID& canonical_) - : overscaledZ(overscaledZ_), canonical(canonical_) { - assert(overscaledZ >= canonical.z); -} - -inline OverscaledTileID::OverscaledTileID(uint8_t overscaledZ_, CanonicalTileID&& canonical_) - : overscaledZ(overscaledZ_), canonical(std::forward<CanonicalTileID>(canonical_)) { +inline OverscaledTileID::OverscaledTileID(uint8_t overscaledZ_, CanonicalTileID canonical_) + : overscaledZ(overscaledZ_), canonical(std::move(canonical_)) { assert(overscaledZ >= canonical.z); } @@ -216,12 +209,8 @@ inline UnwrappedTileID::UnwrappedTileID(uint8_t z_, int64_t x_, int64_t y_) y_ < 0 ? 0 : std::min(static_cast<uint32_t>(y_), static_cast<uint32_t>(1ull << z_) - 1)) { } -inline UnwrappedTileID::UnwrappedTileID(int16_t wrap_, const CanonicalTileID& canonical_) - : wrap(wrap_), canonical(canonical_) { -} - -inline UnwrappedTileID::UnwrappedTileID(int16_t wrap_, CanonicalTileID&& canonical_) - : wrap(wrap_), canonical(std::forward<CanonicalTileID>(canonical_)) { +inline UnwrappedTileID::UnwrappedTileID(int16_t wrap_, CanonicalTileID canonical_) + : wrap(wrap_), canonical(std::move(canonical_)) { } inline bool UnwrappedTileID::operator==(const UnwrappedTileID& rhs) const { diff --git a/src/mbgl/tile/tile_worker.cpp b/src/mbgl/tile/tile_worker.cpp index b47477015d..ea8cc5b1ed 100644 --- a/src/mbgl/tile/tile_worker.cpp +++ b/src/mbgl/tile/tile_worker.cpp @@ -19,14 +19,14 @@ namespace mbgl { using namespace mbgl::style; -TileWorker::TileWorker(const OverscaledTileID& id_, +TileWorker::TileWorker(OverscaledTileID id_, std::string sourceID_, SpriteStore& spriteStore_, GlyphAtlas& glyphAtlas_, GlyphStore& glyphStore_, const util::Atomic<bool>& obsolete_, const MapMode mode_) - : id(id_), + : id(std::move(id_)), sourceID(std::move(sourceID_)), spriteStore(spriteStore_), glyphAtlas(glyphAtlas_), diff --git a/src/mbgl/tile/tile_worker.hpp b/src/mbgl/tile/tile_worker.hpp index f51e47b5bb..34588645a4 100644 --- a/src/mbgl/tile/tile_worker.hpp +++ b/src/mbgl/tile/tile_worker.hpp @@ -45,7 +45,7 @@ using TileParseResult = variant< class TileWorker : public util::noncopyable { public: - TileWorker(const OverscaledTileID&, + TileWorker(OverscaledTileID, std::string sourceID, SpriteStore&, GlyphAtlas&, diff --git a/src/mbgl/util/stopwatch.cpp b/src/mbgl/util/stopwatch.cpp index bbc6bfba0c..8cf0f7fd22 100644 --- a/src/mbgl/util/stopwatch.cpp +++ b/src/mbgl/util/stopwatch.cpp @@ -15,11 +15,11 @@ stopwatch::stopwatch(Event event_) stopwatch::stopwatch(EventSeverity severity_, Event event_) : severity(severity_), event(event_), start(Clock::now()) {} -stopwatch::stopwatch(const std::string &name_, Event event_) - : name(name_), event(event_), start(Clock::now()) {} +stopwatch::stopwatch(std::string name_, Event event_) + : name(std::move(name_)), event(event_), start(Clock::now()) {} -stopwatch::stopwatch(const std::string &name_, EventSeverity severity_, Event event_) - : name(name_), severity(severity_), event(event_), start(Clock::now()) {} +stopwatch::stopwatch(std::string name_, EventSeverity severity_, Event event_) + : name(std::move(name_)), severity(severity_), event(event_), start(Clock::now()) {} void stopwatch::report(const std::string &name_) { Duration duration = Clock::now() - start; diff --git a/src/mbgl/util/stopwatch.hpp b/src/mbgl/util/stopwatch.hpp index 23086b1747..ca6a4125f7 100644 --- a/src/mbgl/util/stopwatch.hpp +++ b/src/mbgl/util/stopwatch.hpp @@ -13,8 +13,8 @@ class stopwatch { public: stopwatch(Event event = Event::General); stopwatch(EventSeverity severity, Event event = Event::General); - stopwatch(const std::string &name, Event event = Event::General); - stopwatch(const std::string &name, EventSeverity severity, Event event = Event::General); + stopwatch(std::string name, Event event = Event::General); + stopwatch(std::string name, EventSeverity severity, Event event = Event::General); void report(const std::string &name); ~stopwatch(); diff --git a/src/mbgl/util/thread_context.cpp b/src/mbgl/util/thread_context.cpp index f728e32df7..fe64c2a686 100644 --- a/src/mbgl/util/thread_context.cpp +++ b/src/mbgl/util/thread_context.cpp @@ -1,10 +1,11 @@ #include <mbgl/util/thread_context.hpp> +#include <utility> namespace mbgl { namespace util { -ThreadContext::ThreadContext(const std::string& name_, ThreadPriority priority_) - : name(name_), +ThreadContext::ThreadContext(std::string name_, ThreadPriority priority_) + : name(std::move(name_)), priority(priority_) { } diff --git a/src/mbgl/util/thread_context.hpp b/src/mbgl/util/thread_context.hpp index 60b32b3b2a..a51dede404 100644 --- a/src/mbgl/util/thread_context.hpp +++ b/src/mbgl/util/thread_context.hpp @@ -12,7 +12,7 @@ enum class ThreadPriority : bool { struct ThreadContext { public: - ThreadContext(const std::string& name, ThreadPriority priority = ThreadPriority::Regular); + ThreadContext(std::string name, ThreadPriority priority = ThreadPriority::Regular); std::string name; ThreadPriority priority; diff --git a/test/src/mbgl/test/fixture_log_observer.cpp b/test/src/mbgl/test/fixture_log_observer.cpp index 302fdc7081..11587be15a 100644 --- a/test/src/mbgl/test/fixture_log_observer.cpp +++ b/test/src/mbgl/test/fixture_log_observer.cpp @@ -6,8 +6,8 @@ namespace mbgl { FixtureLog::Message::Message(EventSeverity severity_, Event event_, int64_t code_, - const std::string& msg_) - : severity(severity_), event(event_), code(code_), msg(msg_) { + std::string msg_) + : severity(severity_), event(event_), code(code_), msg(std::move(msg_)) { } bool FixtureLog::Message::operator==(const Message& rhs) const { diff --git a/test/src/mbgl/test/fixture_log_observer.hpp b/test/src/mbgl/test/fixture_log_observer.hpp index 1eabe10095..c66cd42f18 100644 --- a/test/src/mbgl/test/fixture_log_observer.hpp +++ b/test/src/mbgl/test/fixture_log_observer.hpp @@ -12,7 +12,7 @@ namespace mbgl { class FixtureLog { public: struct Message { - Message(EventSeverity severity_, Event event_, int64_t code_, const std::string &msg_); + Message(EventSeverity severity_, Event event_, int64_t code_, std::string msg_); Message(); bool operator==(const Message& rhs) const; diff --git a/test/style/filter.cpp b/test/style/filter.cpp index f8f56d9316..d28ee4a357 100644 --- a/test/style/filter.cpp +++ b/test/style/filter.cpp @@ -16,8 +16,8 @@ typedef std::multimap<std::string, mbgl::Value> Properties; class StubFeature : public GeometryTileFeature { public: - inline StubFeature(const Properties& properties_, FeatureType type_) - : properties(properties_) + inline StubFeature(Properties properties_, FeatureType type_) + : properties(std::move(properties_)) , type(type_) {} |