From d15b9c1f9c1afa29175ba2e398adc680e66147e6 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 20 Mar 2020 12:38:09 +0200 Subject: [core] Fix performance-unnecessary-value-param errors As reported by clang-tidy-8. --- include/mbgl/actor/mailbox.hpp | 2 +- include/mbgl/i18n/collator.hpp | 2 +- include/mbgl/map/map.hpp | 19 ++++++++++++++----- include/mbgl/platform/settings.hpp | 2 +- include/mbgl/renderer/renderer.hpp | 3 +-- include/mbgl/storage/database_file_source.hpp | 2 +- include/mbgl/style/expression/collator.hpp | 2 +- include/mbgl/style/expression/comparison.hpp | 4 ++-- include/mbgl/style/expression/compound_expression.hpp | 2 +- include/mbgl/style/expression/dsl.hpp | 8 ++++---- include/mbgl/style/expression/parsing_context.hpp | 11 +++++------ include/mbgl/style/image.hpp | 2 +- include/mbgl/style/sources/custom_geometry_source.hpp | 2 +- include/mbgl/style/sources/geojson_source.hpp | 2 +- include/mbgl/util/string.hpp | 2 +- 15 files changed, 36 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/mbgl/actor/mailbox.hpp b/include/mbgl/actor/mailbox.hpp index 1e18d593d3..86ea0100fc 100644 --- a/include/mbgl/actor/mailbox.hpp +++ b/include/mbgl/actor/mailbox.hpp @@ -36,7 +36,7 @@ public: void push(std::unique_ptr); void receive(); - static void maybeReceive(std::weak_ptr); + static void maybeReceive(const std::weak_ptr&); static std::function makeClosure(std::weak_ptr); private: diff --git a/include/mbgl/i18n/collator.hpp b/include/mbgl/i18n/collator.hpp index 9db1f804aa..69afbae7d4 100644 --- a/include/mbgl/i18n/collator.hpp +++ b/include/mbgl/i18n/collator.hpp @@ -10,7 +10,7 @@ namespace platform { class Collator { public: - explicit Collator(bool caseSensitive, bool diacriticSensitive, optional locale = nullopt); + explicit Collator(bool caseSensitive, bool diacriticSensitive, const optional& locale = nullopt); int compare(const std::string& lhs, const std::string& rhs) const; std::string resolvedLocale() const; bool operator==(const Collator& other) const; diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 62bb39e8c2..9aa0cb165e 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -60,17 +60,26 @@ public: bool isPanning() const; // Camera - CameraOptions getCameraOptions(optional = {}) const; + CameraOptions getCameraOptions(const optional& = {}) const; void jumpTo(const CameraOptions&); void easeTo(const CameraOptions&, const AnimationOptions&); void flyTo(const CameraOptions&, const AnimationOptions&); void moveBy(const ScreenCoordinate&, const AnimationOptions& = {}); - void scaleBy(double scale, optional anchor, const AnimationOptions& animation = {}); + void scaleBy(double scale, const optional& anchor, const AnimationOptions& animation = {}); void pitchBy(double pitch, const AnimationOptions& animation = {}); void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& = {}); - CameraOptions cameraForLatLngBounds(const LatLngBounds&, const EdgeInsets&, optional bearing = {}, optional pitch = {}) const; - CameraOptions cameraForLatLngs(const std::vector&, const EdgeInsets&, optional bearing = {}, optional pitch = {}) const; - CameraOptions cameraForGeometry(const Geometry&, const EdgeInsets&, optional bearing = {}, optional pitch = {}) const; + CameraOptions cameraForLatLngBounds(const LatLngBounds&, + const EdgeInsets&, + const optional& bearing = {}, + const optional& pitch = {}) const; + CameraOptions cameraForLatLngs(const std::vector&, + const EdgeInsets&, + const optional& bearing = {}, + const optional& pitch = {}) const; + CameraOptions cameraForGeometry(const Geometry&, + const EdgeInsets&, + const optional& bearing = {}, + const optional& pitch = {}) const; LatLngBounds latLngBoundsForCamera(const CameraOptions&) const; LatLngBounds latLngBoundsForCameraUnwrapped(const CameraOptions&) const; diff --git a/include/mbgl/platform/settings.hpp b/include/mbgl/platform/settings.hpp index 80bfe1d60f..722d0d2b3b 100644 --- a/include/mbgl/platform/settings.hpp +++ b/include/mbgl/platform/settings.hpp @@ -26,7 +26,7 @@ public: // Sets multiple setting values by merging current Settings object // with provided `values` object. - void set(mapbox::base::ValueObject values) noexcept; + void set(const mapbox::base::ValueObject& values) noexcept; // Returns setting value for a specified key or NullValue if element // for specified key is missing. diff --git a/include/mbgl/renderer/renderer.hpp b/include/mbgl/renderer/renderer.hpp index 1d71a016b6..79782839ee 100644 --- a/include/mbgl/renderer/renderer.hpp +++ b/include/mbgl/renderer/renderer.hpp @@ -23,8 +23,7 @@ class RendererBackend; class Renderer { public: - Renderer(gfx::RendererBackend&, float pixelRatio_, - const optional localFontFamily = {}); + Renderer(gfx::RendererBackend&, float pixelRatio_, const optional& localFontFamily = {}); ~Renderer(); void markContextLost(); diff --git a/include/mbgl/storage/database_file_source.hpp b/include/mbgl/storage/database_file_source.hpp index 81e5315fd8..31079fcc3d 100644 --- a/include/mbgl/storage/database_file_source.hpp +++ b/include/mbgl/storage/database_file_source.hpp @@ -216,7 +216,7 @@ public: * executed on the database thread; it is the responsibility of the SDK bindings * to re-execute a user-provided callback on the main thread. */ - virtual void deleteOfflineRegion(OfflineRegion, std::function); + virtual void deleteOfflineRegion(OfflineRegion&, std::function); /* * Invalidate all the tiles from an offline region forcing Mapbox GL to revalidate diff --git a/include/mbgl/style/expression/collator.hpp b/include/mbgl/style/expression/collator.hpp index 51ba426fad..95a072618a 100644 --- a/include/mbgl/style/expression/collator.hpp +++ b/include/mbgl/style/expression/collator.hpp @@ -11,7 +11,7 @@ namespace expression { class Collator { public: - Collator(bool caseSensitive, bool diacriticSensitive, optional locale = {}); + Collator(bool caseSensitive, bool diacriticSensitive, const optional& locale = {}); bool operator==(const Collator& other) const; diff --git a/include/mbgl/style/expression/comparison.hpp b/include/mbgl/style/expression/comparison.hpp index cf64f5cd34..df1fbcab9e 100644 --- a/include/mbgl/style/expression/comparison.hpp +++ b/include/mbgl/style/expression/comparison.hpp @@ -15,7 +15,7 @@ ParseResult parseComparison(const mbgl::style::conversion::Convertible&, Parsing class BasicComparison : public Expression { public: - using CompareFunctionType = bool (*) (Value, Value); + using CompareFunctionType = bool (*)(const Value&, const Value&); BasicComparison( std::string op, @@ -38,7 +38,7 @@ private: class CollatorComparison : public Expression { public: - using CompareFunctionType = bool (*) (std::string, std::string, Collator); + using CompareFunctionType = bool (*)(const std::string&, const std::string&, const Collator&); CollatorComparison( std::string op, diff --git a/include/mbgl/style/expression/compound_expression.hpp b/include/mbgl/style/expression/compound_expression.hpp index 57a96d08a0..c6c66c3fc6 100644 --- a/include/mbgl/style/expression/compound_expression.hpp +++ b/include/mbgl/style/expression/compound_expression.hpp @@ -46,7 +46,7 @@ protected: std::vector> args; }; -ParseResult parseCompoundExpression(const std::string name, +ParseResult parseCompoundExpression(const std::string& name, const mbgl::style::conversion::Convertible& value, ParsingContext& ctx); diff --git a/include/mbgl/style/expression/dsl.hpp b/include/mbgl/style/expression/dsl.hpp index 347861abc9..6bb1d22d64 100644 --- a/include/mbgl/style/expression/dsl.hpp +++ b/include/mbgl/style/expression/dsl.hpp @@ -29,13 +29,13 @@ std::unique_ptr createExpression(const mbgl::style::conversion::Conv std::unique_ptr error(std::string); std::unique_ptr literal(const char* value); -std::unique_ptr literal(Value value); +std::unique_ptr literal(const Value& value); std::unique_ptr literal(std::initializer_list value); std::unique_ptr literal(std::initializer_list value); -std::unique_ptr -assertion(type::Type, std::unique_ptr, - std::unique_ptr def = nullptr); +std::unique_ptr assertion(const type::Type&, + std::unique_ptr, + std::unique_ptr def = nullptr); std::unique_ptr number(std::unique_ptr, std::unique_ptr def = nullptr); std::unique_ptr string(std::unique_ptr, diff --git a/include/mbgl/style/expression/parsing_context.hpp b/include/mbgl/style/expression/parsing_context.hpp index 596b136419..40da7c26d0 100644 --- a/include/mbgl/style/expression/parsing_context.hpp +++ b/include/mbgl/style/expression/parsing_context.hpp @@ -93,7 +93,7 @@ public: Parse the given style-spec JSON value as an expression. */ ParseResult parseExpression(const mbgl::style::conversion::Convertible& value, - optional = {}); + const optional& = {}); /* Parse the given style-spec JSON value as an expression intended to be used @@ -108,8 +108,8 @@ public: ParseResult parse(const mbgl::style::conversion::Convertible&, std::size_t, optional = {}, - optional = {}); - + const optional& = {}); + /* Parse a child expression. For use by individual Expression::parse() methods. */ @@ -168,9 +168,8 @@ private: type (either Literal, or the one named in value[0]) and dispatching to the appropriate ParseXxxx::parse(const V&, ParsingContext) method. */ - ParseResult parse(const mbgl::style::conversion::Convertible& value, - optional = {}); - + ParseResult parse(const mbgl::style::conversion::Convertible& value, const optional& = {}); + std::string key; optional expected; std::shared_ptr scope; diff --git a/include/mbgl/style/image.hpp b/include/mbgl/style/image.hpp index dd62d9e0ae..deb4b6f6ce 100644 --- a/include/mbgl/style/image.hpp +++ b/include/mbgl/style/image.hpp @@ -34,7 +34,7 @@ public: bool sdf, ImageStretches stretchX = {}, ImageStretches stretchY = {}, - optional content = nullopt); + const optional& content = nullopt); Image(std::string id, PremultipliedImage&& image, float pixelRatio, diff --git a/include/mbgl/style/sources/custom_geometry_source.hpp b/include/mbgl/style/sources/custom_geometry_source.hpp index 504ec42ea8..250886c209 100644 --- a/include/mbgl/style/sources/custom_geometry_source.hpp +++ b/include/mbgl/style/sources/custom_geometry_source.hpp @@ -37,7 +37,7 @@ public: TileOptions tileOptions; }; public: - CustomGeometrySource(std::string id, CustomGeometrySource::Options options); + CustomGeometrySource(std::string id, const CustomGeometrySource::Options& options); ~CustomGeometrySource() final; void loadDescription(FileSource&) final; void setTileData(const CanonicalTileID&, const GeoJSON&); diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp index 7c75433c6a..9cfcade0ed 100644 --- a/include/mbgl/style/sources/geojson_source.hpp +++ b/include/mbgl/style/sources/geojson_source.hpp @@ -42,7 +42,7 @@ public: using TileFeatures = mapbox::feature::feature_collection; using Features = mapbox::feature::feature_collection; static std::shared_ptr create(const GeoJSON&, - Immutable = GeoJSONOptions::defaultOptions(), + const Immutable& = GeoJSONOptions::defaultOptions(), std::shared_ptr scheduler = nullptr); virtual ~GeoJSONData() = default; diff --git a/include/mbgl/util/string.hpp b/include/mbgl/util/string.hpp index 1e0f512ba8..27c3943c5f 100644 --- a/include/mbgl/util/string.hpp +++ b/include/mbgl/util/string.hpp @@ -65,7 +65,7 @@ inline std::string toString(long double t, bool decimal = false) { return toString(static_cast(t), decimal); } -std::string toString(std::exception_ptr); +std::string toString(const std::exception_ptr &); template std::string toString(T) = delete; -- cgit v1.2.1