diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-06-17 13:07:27 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-06-18 23:46:50 +0300 |
commit | c20c1d6a6b3eb301db88ca3e74993f445cc4d839 (patch) | |
tree | 7011952bc5cc49d62b2be4b96ba3c3c7bbd3e54d /src/mbgl | |
parent | 41497e9c4174d310f3a62548f3cfeb9da2852849 (diff) | |
download | qtlocation-mapboxgl-c20c1d6a6b3eb301db88ca3e74993f445cc4d839.tar.gz |
[core] Avoid redundant 'inline' usage
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/annotation/symbol_annotation_impl.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/geometry/buffer.hpp | 8 | ||||
-rw-r--r-- | src/mbgl/geometry/vao.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/bucket.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/fill_bucket.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/sprite/sprite_atlas.hpp | 16 | ||||
-rw-r--r-- | src/mbgl/sprite/sprite_parser.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/style/property_evaluator.cpp | 44 | ||||
-rw-r--r-- | src/mbgl/text/collision_feature.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/text/glyph.hpp | 10 | ||||
-rw-r--r-- | src/mbgl/text/placement_config.hpp | 6 | ||||
-rw-r--r-- | src/mbgl/text/shaping.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/util/clip_id.hpp | 8 | ||||
-rw-r--r-- | src/mbgl/util/dtoa.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/util/dtoa.hpp | 9 | ||||
-rw-r--r-- | src/mbgl/util/exclusive.hpp | 10 | ||||
-rw-r--r-- | src/mbgl/util/geo.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/util/io.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/util/math.hpp | 26 | ||||
-rw-r--r-- | src/mbgl/util/ptr.hpp | 6 | ||||
-rw-r--r-- | src/mbgl/util/rect.hpp | 10 | ||||
-rw-r--r-- | src/mbgl/util/stopwatch.hpp | 12 | ||||
-rw-r--r-- | src/mbgl/util/thread_local.hpp | 10 |
23 files changed, 109 insertions, 108 deletions
diff --git a/src/mbgl/annotation/symbol_annotation_impl.hpp b/src/mbgl/annotation/symbol_annotation_impl.hpp index 48ab321500..2e98f2414c 100644 --- a/src/mbgl/annotation/symbol_annotation_impl.hpp +++ b/src/mbgl/annotation/symbol_annotation_impl.hpp @@ -55,7 +55,7 @@ namespace index { template <> struct indexable<std::shared_ptr<const mbgl::SymbolAnnotationImpl>> { using result_type = mbgl::LatLng; - inline mbgl::LatLng operator()(const std::shared_ptr<const mbgl::SymbolAnnotationImpl>& v) const { + mbgl::LatLng operator()(const std::shared_ptr<const mbgl::SymbolAnnotationImpl>& v) const { const mbgl::Point<double>& p = v->annotation.geometry; return mbgl::LatLng(p.y, p.x); } diff --git a/src/mbgl/geometry/buffer.hpp b/src/mbgl/geometry/buffer.hpp index 6465b6f8e3..d372a040bf 100644 --- a/src/mbgl/geometry/buffer.hpp +++ b/src/mbgl/geometry/buffer.hpp @@ -27,11 +27,11 @@ public: // Returns the number of elements in this buffer. This is not the number of // bytes, but rather the number of coordinates with associated information. - inline GLsizei index() const { + GLsizei index() const { return static_cast<GLsizei>(pos / itemSize); } - inline bool empty() const { + bool empty() const { return pos == 0; } @@ -65,7 +65,7 @@ public: } // Uploads the buffer to the GPU to be available when we need it. - inline void upload(gl::ObjectStore& store) { + void upload(gl::ObjectStore& store) { if (!buffer) { bind(store); } @@ -73,7 +73,7 @@ public: protected: // increase the buffer size by at least /required/ bytes. - inline void *addElement() { + void *addElement() { if (buffer) { throw std::runtime_error("Can't add elements after buffer was bound to GPU"); } diff --git a/src/mbgl/geometry/vao.hpp b/src/mbgl/geometry/vao.hpp index 93489fcc7b..6821be182a 100644 --- a/src/mbgl/geometry/vao.hpp +++ b/src/mbgl/geometry/vao.hpp @@ -20,7 +20,7 @@ public: ~VertexArrayObject(); template <typename Shader, typename VertexBuffer> - inline void bind(Shader& shader, VertexBuffer &vertexBuffer, GLbyte *offset, gl::ObjectStore& store) { + void bind(Shader& shader, VertexBuffer &vertexBuffer, GLbyte *offset, gl::ObjectStore& store) { bindVertexArrayObject(store); if (bound_shader == 0) { vertexBuffer.bind(store); @@ -34,7 +34,7 @@ public: } template <typename Shader, typename VertexBuffer, typename ElementsBuffer> - inline void bind(Shader& shader, VertexBuffer &vertexBuffer, ElementsBuffer &elementsBuffer, GLbyte *offset, gl::ObjectStore& store) { + void bind(Shader& shader, VertexBuffer &vertexBuffer, ElementsBuffer &elementsBuffer, GLbyte *offset, gl::ObjectStore& store) { bindVertexArrayObject(store); if (bound_shader == 0) { vertexBuffer.bind(store); diff --git a/src/mbgl/renderer/bucket.hpp b/src/mbgl/renderer/bucket.hpp index 510f22ed14..9c572113be 100644 --- a/src/mbgl/renderer/bucket.hpp +++ b/src/mbgl/renderer/bucket.hpp @@ -41,7 +41,7 @@ public: virtual bool needsClipping() const = 0; - inline bool needsUpload() const { + bool needsUpload() const { return !uploaded; } diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp index df8b01c474..cd69f43375 100644 --- a/src/mbgl/renderer/fill_bucket.cpp +++ b/src/mbgl/renderer/fill_bucket.cpp @@ -15,11 +15,11 @@ namespace mapbox { namespace util { template <> struct nth<0, mbgl::GeometryCoordinate> { - inline static int64_t get(const mbgl::GeometryCoordinate& t) { return t.x; }; + static int64_t get(const mbgl::GeometryCoordinate& t) { return t.x; }; }; template <> struct nth<1, mbgl::GeometryCoordinate> { - inline static int64_t get(const mbgl::GeometryCoordinate& t) { return t.y; }; + static int64_t get(const mbgl::GeometryCoordinate& t) { return t.y; }; }; } // namespace util } // namespace mapbox diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp index 5d8e05a60c..4d1ee1c38c 100644 --- a/src/mbgl/sprite/sprite_atlas.hpp +++ b/src/mbgl/sprite/sprite_atlas.hpp @@ -56,14 +56,14 @@ public: // the texture is only bound when the data is out of date (=dirty). void upload(gl::ObjectStore&); - inline dimension getWidth() const { return width; } - inline dimension getHeight() const { return height; } - inline dimension getTextureWidth() const { return pixelWidth; } - inline dimension getTextureHeight() const { return pixelHeight; } - inline float getPixelRatio() const { return pixelRatio; } + dimension getWidth() const { return width; } + dimension getHeight() const { return height; } + dimension getTextureWidth() const { return pixelWidth; } + dimension getTextureHeight() const { return pixelHeight; } + float getPixelRatio() const { return pixelRatio; } // Only for use in tests. - inline const uint32_t* getData() const { return data.get(); } + const uint32_t* getData() const { return data.get(); } private: const GLsizei width, height; @@ -71,8 +71,8 @@ private: const float pixelRatio; struct Holder : private util::noncopyable { - inline Holder(std::shared_ptr<const SpriteImage>, Rect<dimension>); - inline Holder(Holder&&); + Holder(std::shared_ptr<const SpriteImage>, Rect<dimension>); + Holder(Holder&&); std::shared_ptr<const SpriteImage> spriteImage; const Rect<dimension> pos; }; diff --git a/src/mbgl/sprite/sprite_parser.cpp b/src/mbgl/sprite/sprite_parser.cpp index 9fbca51112..190ac66e14 100644 --- a/src/mbgl/sprite/sprite_parser.cpp +++ b/src/mbgl/sprite/sprite_parser.cpp @@ -46,7 +46,7 @@ SpriteImagePtr createSpriteImage(const PremultipliedImage& image, namespace { -inline uint16_t getUInt16(const JSValue& value, const char* name, const uint16_t def = 0) { +uint16_t getUInt16(const JSValue& value, const char* name, const uint16_t def = 0) { if (value.HasMember(name)) { auto& v = value[name]; if (v.IsUint() && v.GetUint() <= std::numeric_limits<uint16_t>::max()) { @@ -60,7 +60,7 @@ inline uint16_t getUInt16(const JSValue& value, const char* name, const uint16_t return def; } -inline double getDouble(const JSValue& value, const char* name, const double def = 0) { +double getDouble(const JSValue& value, const char* name, const double def = 0) { if (value.HasMember(name)) { auto& v = value[name]; if (v.IsNumber()) { @@ -73,7 +73,7 @@ inline double getDouble(const JSValue& value, const char* name, const double def return def; } -inline bool getBoolean(const JSValue& value, const char* name, const bool def = false) { +bool getBoolean(const JSValue& value, const char* name, const bool def = false) { if (value.HasMember(name)) { auto& v = value[name]; if (v.IsBool()) { diff --git a/src/mbgl/style/property_evaluator.cpp b/src/mbgl/style/property_evaluator.cpp index 3394d69e41..fd31451d72 100644 --- a/src/mbgl/style/property_evaluator.cpp +++ b/src/mbgl/style/property_evaluator.cpp @@ -11,27 +11,27 @@ namespace mbgl { namespace style { template <typename T> -inline T defaultStopsValue(); - -template <> inline bool defaultStopsValue() { return true; } -template <> inline float defaultStopsValue() { return 1.0f; } -template <> inline Color defaultStopsValue() { return { 0, 0, 0, 1 }; } -template <> inline std::vector<float> defaultStopsValue() { return {{ 1, 0 }}; } -template <> inline std::vector<std::string> defaultStopsValue() { return {{}}; } -template <> inline std::array<float, 2> defaultStopsValue() { return {{ 0, 0 }}; } -template <> inline std::array<float, 4> defaultStopsValue() { return {{ 0, 0, 0, 0 }}; } - -template <> inline std::string defaultStopsValue() { return {}; } -template <> inline TranslateAnchorType defaultStopsValue() { return {}; } -template <> inline RotateAnchorType defaultStopsValue() { return {}; } -template <> inline LineCapType defaultStopsValue() { return {}; } -template <> inline LineJoinType defaultStopsValue() { return {}; } -template <> inline SymbolPlacementType defaultStopsValue() { return {}; } -template <> inline TextAnchorType defaultStopsValue() { return {}; } -template <> inline TextJustifyType defaultStopsValue() { return {}; } -template <> inline TextTransformType defaultStopsValue() { return {}; } -template <> inline AlignmentType defaultStopsValue() { return {}; } -template <> inline IconTextFitType defaultStopsValue() { return {}; }; +T defaultStopsValue(); + +template <> bool defaultStopsValue() { return true; } +template <> float defaultStopsValue() { return 1.0f; } +template <> Color defaultStopsValue() { return { 0, 0, 0, 1 }; } +template <> std::vector<float> defaultStopsValue() { return {{ 1, 0 }}; } +template <> std::vector<std::string> defaultStopsValue() { return {{}}; } +template <> std::array<float, 2> defaultStopsValue() { return {{ 0, 0 }}; } +template <> std::array<float, 4> defaultStopsValue() { return {{ 0, 0, 0, 0 }}; } + +template <> std::string defaultStopsValue() { return {}; } +template <> TranslateAnchorType defaultStopsValue() { return {}; } +template <> RotateAnchorType defaultStopsValue() { return {}; } +template <> LineCapType defaultStopsValue() { return {}; } +template <> LineJoinType defaultStopsValue() { return {}; } +template <> SymbolPlacementType defaultStopsValue() { return {}; } +template <> TextAnchorType defaultStopsValue() { return {}; } +template <> TextJustifyType defaultStopsValue() { return {}; } +template <> TextTransformType defaultStopsValue() { return {}; } +template <> AlignmentType defaultStopsValue() { return {}; } +template <> IconTextFitType defaultStopsValue() { return {}; }; template <typename T> T PropertyEvaluator<T>::operator()(const Function<T>& fn) const { @@ -114,7 +114,7 @@ Faded<T> CrossFadedPropertyEvaluator<T>::operator()(const T& constant) const { } template <typename T> -inline T getBiggestStopLessThan(const Function<T>& function, float z) { +T getBiggestStopLessThan(const Function<T>& function, float z) { const auto& stops = function.getStops(); for (uint32_t i = 0; i < stops.size(); i++) { if (stops[i].first > z) { diff --git a/src/mbgl/text/collision_feature.hpp b/src/mbgl/text/collision_feature.hpp index f0bb0f7340..5c0095bc6d 100644 --- a/src/mbgl/text/collision_feature.hpp +++ b/src/mbgl/text/collision_feature.hpp @@ -33,7 +33,7 @@ namespace mbgl { class CollisionFeature { public: // for text - inline explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, + explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const Shaping &shapedText, const float boxScale, const float padding, const bool alongLine, const IndexedSubfeature& indexedFeature_) : CollisionFeature(line, anchor, @@ -41,7 +41,7 @@ namespace mbgl { boxScale, padding, alongLine, indexedFeature_, false) {} // for icons - inline explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, + explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const PositionedIcon &shapedIcon, const float boxScale, const float padding, const bool alongLine, const IndexedSubfeature& indexedFeature_) : CollisionFeature(line, anchor, diff --git a/src/mbgl/text/glyph.hpp b/src/mbgl/text/glyph.hpp index ce07b1b3fd..975dc4ad23 100644 --- a/src/mbgl/text/glyph.hpp +++ b/src/mbgl/text/glyph.hpp @@ -28,8 +28,8 @@ struct GlyphMetrics { }; struct Glyph { - inline explicit Glyph() : rect(0, 0, 0, 0), metrics() {} - inline explicit Glyph(Rect<uint16_t> rect_, GlyphMetrics metrics_) + explicit Glyph() : rect(0, 0, 0, 0), metrics() {} + explicit Glyph(Rect<uint16_t> rect_, GlyphMetrics metrics_) : rect(std::move(rect_)), metrics(std::move(metrics_)) {} operator bool() const { @@ -44,7 +44,7 @@ typedef std::map<uint32_t, Glyph> GlyphPositions; class PositionedGlyph { public: - inline explicit PositionedGlyph(uint32_t glyph_, float x_, float y_) + explicit PositionedGlyph(uint32_t glyph_, float x_, float y_) : glyph(glyph_), x(x_), y(y_) {} uint32_t glyph = 0; @@ -54,8 +54,8 @@ public: class Shaping { public: - inline explicit Shaping() : top(0), bottom(0), left(0), right(0) {} - inline explicit Shaping(float x, float y, std::u32string text_) + explicit Shaping() : top(0), bottom(0), left(0), right(0) {} + explicit Shaping(float x, float y, std::u32string text_) : text(std::move(text_)), top(y), bottom(y), left(x), right(x) {} std::vector<PositionedGlyph> positionedGlyphs; std::u32string text; diff --git a/src/mbgl/text/placement_config.hpp b/src/mbgl/text/placement_config.hpp index 75345b89e8..7e61cabc24 100644 --- a/src/mbgl/text/placement_config.hpp +++ b/src/mbgl/text/placement_config.hpp @@ -4,15 +4,15 @@ namespace mbgl { class PlacementConfig { public: - inline PlacementConfig(float angle_ = 0, float pitch_ = 0, bool debug_ = false) + PlacementConfig(float angle_ = 0, float pitch_ = 0, bool debug_ = false) : angle(angle_), pitch(pitch_), debug(debug_) { } - inline bool operator==(const PlacementConfig& rhs) const { + bool operator==(const PlacementConfig& rhs) const { return angle == rhs.angle && pitch == rhs.pitch && debug == rhs.debug; } - inline bool operator!=(const PlacementConfig& rhs) const { + bool operator!=(const PlacementConfig& rhs) const { return !operator==(rhs); } diff --git a/src/mbgl/text/shaping.hpp b/src/mbgl/text/shaping.hpp index c33b3788d5..cd5e8105fd 100644 --- a/src/mbgl/text/shaping.hpp +++ b/src/mbgl/text/shaping.hpp @@ -15,8 +15,8 @@ class SymbolLayoutProperties; class PositionedIcon { public: - inline explicit PositionedIcon() {} - inline explicit PositionedIcon(const SpriteAtlasElement& _image, + explicit PositionedIcon() {} + explicit PositionedIcon(const SpriteAtlasElement& _image, float _top, float _bottom, float _left, float _right) : image(_image), top(_top), bottom(_bottom), left(_left), right(_right) {} diff --git a/src/mbgl/util/clip_id.hpp b/src/mbgl/util/clip_id.hpp index e68f21e741..de2dc51919 100644 --- a/src/mbgl/util/clip_id.hpp +++ b/src/mbgl/util/clip_id.hpp @@ -12,17 +12,17 @@ namespace mbgl { struct ClipID { - inline ClipID() {} - inline ClipID(const std::string &mask_, const std::string &reference_) : mask(mask_), reference(reference_) {} + ClipID() {} + ClipID(const std::string &mask_, const std::string &reference_) : mask(mask_), reference(reference_) {} std::bitset<8> mask; std::bitset<8> reference; - inline bool operator==(const ClipID &other) const { + bool operator==(const ClipID &other) const { return mask == other.mask && reference == other.reference; } - inline ClipID& operator|=(const ClipID &other) { + ClipID& operator|=(const ClipID &other) { mask |= other.mask; reference |= other.reference; return *this; diff --git a/src/mbgl/util/dtoa.cpp b/src/mbgl/util/dtoa.cpp index 7ccee345f6..dd4fba0f89 100644 --- a/src/mbgl/util/dtoa.cpp +++ b/src/mbgl/util/dtoa.cpp @@ -9,7 +9,7 @@ namespace { // From https://github.com/miloyip/rapidjson/blob/master/include/rapidjson/internal/dtoa.h -inline char* Prettify(char* buffer, int length, int k) { +char* Prettify(char* buffer, int length, int k) { constexpr int maxDecimalPlaces = 324; const int kk = length + k; // 10^(kk-1) <= v < 10^kk @@ -93,5 +93,13 @@ char* dtoa(double value, char* buffer) { } } +std::string dtoa(double value) { + std::string data; + data.resize(25); + auto end = dtoa(value, const_cast<char*>(data.data())); + data.resize(end - data.data()); + return data; +} + } // namespace util } // namespace mbgl diff --git a/src/mbgl/util/dtoa.hpp b/src/mbgl/util/dtoa.hpp index 17614732db..db7d309452 100644 --- a/src/mbgl/util/dtoa.hpp +++ b/src/mbgl/util/dtoa.hpp @@ -6,14 +6,7 @@ namespace mbgl { namespace util { char* dtoa(double value, char* buffer); - -inline std::string dtoa(double value) { - std::string data; - data.resize(25); - auto end = dtoa(value, const_cast<char*>(data.data())); - data.resize(end - data.data()); - return data; -} +std::string dtoa(double value); } // end namespace util } // end namespace mbgl diff --git a/src/mbgl/util/exclusive.hpp b/src/mbgl/util/exclusive.hpp index 946604af69..844588dc90 100644 --- a/src/mbgl/util/exclusive.hpp +++ b/src/mbgl/util/exclusive.hpp @@ -10,12 +10,12 @@ namespace util { template <class T> class exclusive { public: - inline exclusive(T* val, std::unique_ptr<std::lock_guard<std::mutex>> mtx) : ptr(val), lock(std::move(mtx)) {} + exclusive(T* val, std::unique_ptr<std::lock_guard<std::mutex>> mtx) : ptr(val), lock(std::move(mtx)) {} - inline T* operator->() { return ptr; } - inline const T* operator->() const { return ptr; } - inline T* operator*() { return ptr; } - inline const T* operator*() const { return ptr; } + T* operator->() { return ptr; } + const T* operator->() const { return ptr; } + T* operator*() { return ptr; } + const T* operator*() const { return ptr; } private: T *ptr; diff --git a/src/mbgl/util/geo.cpp b/src/mbgl/util/geo.cpp index dd40af882b..fe24334e82 100644 --- a/src/mbgl/util/geo.cpp +++ b/src/mbgl/util/geo.cpp @@ -8,12 +8,12 @@ namespace mbgl { namespace { -inline double lat(const uint8_t z, const int64_t y) { +double lat(const uint8_t z, const int64_t y) { const double n = M_PI - 2.0 * M_PI * y / std::pow(2.0, z); return util::RAD2DEG * std::atan(0.5 * (std::exp(n) - std::exp(-n))); } -inline double lon(const uint8_t z, const int64_t x) { +double lon(const uint8_t z, const int64_t x) { return x / std::pow(2.0, z) * util::DEGREES_MAX - util::LONGITUDE_MAX; } diff --git a/src/mbgl/util/io.hpp b/src/mbgl/util/io.hpp index 2679eb5360..795a465328 100644 --- a/src/mbgl/util/io.hpp +++ b/src/mbgl/util/io.hpp @@ -7,7 +7,7 @@ namespace mbgl { namespace util { struct IOException : std::runtime_error { - inline IOException(int err, const char* msg) : std::runtime_error(msg), code(err) { + IOException(int err, const char* msg) : std::runtime_error(msg), code(err) { } const int code = 0; }; diff --git a/src/mbgl/util/math.hpp b/src/mbgl/util/math.hpp index bfedc2a421..5d4220d0a2 100644 --- a/src/mbgl/util/math.hpp +++ b/src/mbgl/util/math.hpp @@ -14,18 +14,18 @@ namespace util { // Find the angle of the two vectors, solving the formula for the cross product // a x b = |a||b|sin(θ) for θ. template <typename T = double, typename S> -inline T angle_between(const Point<S>& a, const Point<S>& b) { +T angle_between(const Point<S>& a, const Point<S>& b) { return std::atan2((a.x * b.y - a.y * b.x), a.x * b.x + a.y * b.y); } template <typename T = double, typename S> -inline T angle_to(const Point<S>& a, const Point<S>& b) { +T angle_to(const Point<S>& a, const Point<S>& b) { return std::atan2(a.y - b.y, a.x - b.x); } // Reflect an angle around 0 degrees template <typename T> -inline std::array<T, 2> flip(const std::array<T, 2>& c) { +std::array<T, 2> flip(const std::array<T, 2>& c) { return {{ static_cast<T>(2 * M_PI - c[0]), static_cast<T>(2 * M_PI - c[1]) @@ -33,7 +33,7 @@ inline std::array<T, 2> flip(const std::array<T, 2>& c) { } template <typename T, typename S1, typename S2> -inline Point<T> normal(const S1& a, const S2& b) { +Point<T> normal(const S1& a, const S2& b) { T dx = b.x - a.x; T dy = b.y - a.y; T c = std::sqrt(dx * dx + dy * dy); @@ -41,12 +41,12 @@ inline Point<T> normal(const S1& a, const S2& b) { } template <typename T> -inline T perp(const T& a) { +T perp(const T& a) { return T(-a.y, a.x); } template <typename T, typename S1, typename S2> -inline T dist(const S1& a, const S2& b) { +T dist(const S1& a, const S2& b) { T dx = b.x - a.x; T dy = b.y - a.y; T c = std::sqrt(dx * dx + dy * dy); @@ -54,7 +54,7 @@ inline T dist(const S1& a, const S2& b) { } template <typename T, typename S1, typename S2> -inline T distSqr(const S1& a, const S2& b) { +T distSqr(const S1& a, const S2& b) { T dx = b.x - a.x; T dy = b.y - a.y; T c = dx * dx + dy * dy; @@ -62,23 +62,23 @@ inline T distSqr(const S1& a, const S2& b) { } template <typename T> -inline T round(const T& a) { +T round(const T& a) { return T(::round(a.x), ::round(a.y)); } template <typename T> -inline T length(T a, T b) { +T length(T a, T b) { return std::sqrt(a * a + b * b); } // Take the magnitude of vector a. template <typename T = double, typename S> -inline T mag(const S& a) { +T mag(const S& a) { return std::sqrt(a.x * a.x + a.y * a.y); } template <typename S> -inline S unit(const S& a) { +S unit(const S& a) { auto magnitude = mag(a); if (magnitude == 0) { return a; @@ -87,7 +87,7 @@ inline S unit(const S& a) { } template <typename T, typename S = double> -inline T rotate(const T& a, S angle) { +T rotate(const T& a, S angle) { S cos = std::cos(angle); S sin = std::sin(angle); S x = cos * a.x - sin * a.y; @@ -96,7 +96,7 @@ inline T rotate(const T& a, S angle) { } template <typename T> -inline Point<T> matrixMultiply(const std::array<T, 4>& m, const Point<T>& p) { +Point<T> matrixMultiply(const std::array<T, 4>& m, const Point<T>& p) { return Point<T>(m[0] * p.x + m[1] * p.y, m[2] * p.x + m[3] * p.y); } diff --git a/src/mbgl/util/ptr.hpp b/src/mbgl/util/ptr.hpp index 2dc8118181..87c4e9f7cf 100644 --- a/src/mbgl/util/ptr.hpp +++ b/src/mbgl/util/ptr.hpp @@ -10,14 +10,14 @@ template <typename T> class ptr : public ::std::shared_ptr<T> { public: template <typename... Args> - inline ptr(Args &&... args) + ptr(Args &&... args) : ::std::shared_ptr<T>(::std::forward<Args>(args)...) {} - inline auto operator->() const -> decltype(this->::std::shared_ptr<T>::operator->()) { + auto operator->() const -> decltype(this->::std::shared_ptr<T>::operator->()) { assert(*this); return ::std::shared_ptr<T>::operator->(); } - inline auto operator*() const -> decltype(this->::std::shared_ptr<T>::operator*()) { + auto operator*() const -> decltype(this->::std::shared_ptr<T>::operator*()) { assert(*this); return ::std::shared_ptr<T>::operator*(); } diff --git a/src/mbgl/util/rect.hpp b/src/mbgl/util/rect.hpp index 2b877db40d..f5937f5c94 100644 --- a/src/mbgl/util/rect.hpp +++ b/src/mbgl/util/rect.hpp @@ -4,21 +4,21 @@ namespace mbgl { template <typename T> struct Rect { - inline Rect() = default; - inline Rect(T x_, T y_, T w_, T h_) : x(x_), y(y_), w(w_), h(h_) {} + Rect() = default; + Rect(T x_, T y_, T w_, T h_) : x(x_), y(y_), w(w_), h(h_) {} T x = 0, y = 0; T w = 0, h = 0; template <typename Number> - inline Rect operator *(Number value) const { + Rect operator *(Number value) const { return Rect(x * value, y * value, w * value, h * value); } template <typename R> - inline bool operator==(const R& r) const { + bool operator==(const R& r) const { return x == r.x && y == r.y && w == r.w && h == r.h; } - inline bool hasArea() const { return w != 0 && h != 0; } + bool hasArea() const { return w != 0 && h != 0; } }; } // namespace mbgl diff --git a/src/mbgl/util/stopwatch.hpp b/src/mbgl/util/stopwatch.hpp index ca6a4125f7..74cc2c412d 100644 --- a/src/mbgl/util/stopwatch.hpp +++ b/src/mbgl/util/stopwatch.hpp @@ -26,12 +26,12 @@ private: }; #else class stopwatch { - inline stopwatch(Event event = Event::General); - inline stopwatch(EventSeverity severity, Event event = Event::General); - inline stopwatch(const std::string &name, Event event = Event::General); - inline stopwatch(const std::string &name, EventSeverity severity, Event event = Event::General); - inline void report(const std::string &name) {} - inline ~stopwatch() {} + 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); + void report(const std::string &name) {} + ~stopwatch() {} }; #endif } // namespace util diff --git a/src/mbgl/util/thread_local.hpp b/src/mbgl/util/thread_local.hpp index c3364c5d42..67e3842ec6 100644 --- a/src/mbgl/util/thread_local.hpp +++ b/src/mbgl/util/thread_local.hpp @@ -12,12 +12,12 @@ namespace util { template <class T> class ThreadLocal : public noncopyable { public: - inline ThreadLocal(T* val) { + ThreadLocal(T* val) { ThreadLocal(); set(val); } - inline ThreadLocal() { + ThreadLocal() { int ret = pthread_key_create(&key, [](void *ptr) { delete reinterpret_cast<T *>(ptr); }); @@ -27,13 +27,13 @@ public: } } - inline ~ThreadLocal() { + ~ThreadLocal() { if (pthread_key_delete(key)) { throw std::runtime_error("Failed to delete local storage key."); } } - inline T* get() { + T* get() { T* ret = reinterpret_cast<T*>(pthread_getspecific(key)); if (!ret) { return nullptr; @@ -42,7 +42,7 @@ public: return ret; } - inline void set(T* ptr) { + void set(T* ptr) { if (pthread_setspecific(key, ptr)) { throw std::runtime_error("Failed to set local storage."); } |