From 0a92bc147f91f3ecacdf66d995f01f9577107a86 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 15 Feb 2018 09:06:13 +0100 Subject: clean up "static" and "constexpr" types - use `static constexpr inline' to avoid requiring explicit declarations in object code - use `const Foo* const' to maybe put into readonly binary segment (at least for ELF DSOs) - `constexpr' in function scope has storage, avoid `static' - don't use `constexpr' where there's no advantage, like arrays We'd like to avoid overhead of atomic initialization for each function call. No idea how `static constexpr' requiring storage in the standard plays with atomic initialization requirement. Hearsay points that `constexpr' without `static' in block scope behaves more to our liking. It's all hazy though. I'm not 100% sure if `static inline constexpr' has any storage. Hopefully none, like a #define, and stuff bigger than registers gets coalesced within the same module, with small stuff being immediates. --- pose-widget/pose-widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pose-widget/pose-widget.cpp') diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp index 69861b24..0880fd1e 100644 --- a/pose-widget/pose-widget.cpp +++ b/pose-widget/pose-widget.cpp @@ -287,7 +287,7 @@ void pose_transform::project_quad_texture() const int orig_depth = tex.depth() / 8; const int dest_depth = image.depth() / 8; - static constexpr int const_depth = 4; + constexpr int const_depth = 4; if (unlikely(orig_depth != const_depth || dest_depth != const_depth)) { -- cgit v1.2.3 From 9d4f5245630d2cac5f4a479dee2f6a7b358c8ef9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 16 Feb 2018 11:03:01 +0100 Subject: compat/macros: cleanup Remove cruft, adjust usages. --- compat/macros.hpp | 30 ++---------------------------- pose-widget/pose-widget.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 35 deletions(-) (limited to 'pose-widget/pose-widget.cpp') diff --git a/compat/macros.hpp b/compat/macros.hpp index 7c017d3e..df71b1f3 100644 --- a/compat/macros.hpp +++ b/compat/macros.hpp @@ -21,28 +21,14 @@ # define never_inline #endif -#if defined __GNUG__ +#if defined __cplusplus # define restrict_ptr __restrict -#elif defined _MSC_VER -# define restrict_ptr __restrict -#else -# define restrict_ptr -#endif - -#if defined _MSC_VER -# define restrict_ref restrict_ptr -#elif defined __GNUG__ -# define restrict_ref restrict_ptr -#else -# define restrict_ref #endif #if defined _MSC_VER # define force_inline __forceinline -#elif defined __GNUG__ -# define force_inline __attribute__((always_inline, gnu_inline)) inline #else -# define force_inline inline +# define force_inline __attribute__((always_inline, gnu_inline)) inline #endif #ifdef Q_CREATOR_RUN @@ -53,18 +39,6 @@ # define warn_result_unused __attribute__((warn_unused_result)) #endif -#if defined __GNUG__ -# define unused(t, i) t __attribute__((unused)) i -#else -# define unused(t, i) t -#endif - -#if defined _MSC_VER -# define aligned_struct(x) struct __declspec(align(x)) -#else -# define aligned_struct(x) struct __attribute__((__aligned__(x))) -#endif - #if defined __GNUC__ # define likely(x) __builtin_expect(!!(x),1) # define unlikely(x) __builtin_expect(!!(x),0) diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp index 0880fd1e..60d41aa5 100644 --- a/pose-widget/pose-widget.cpp +++ b/pose-widget/pose-widget.cpp @@ -304,9 +304,9 @@ void pose_transform::project_quad_texture() for (int y = 0; y < dist.y(); y++) for (int x = 0; x < dist.x(); x++) { - uv_& restrict_ref uv = uv_vec[y * dist.x() + x]; - if (!t.barycentric_coords(vec2(x + min.x(), y + min.y()), uv.coords, uv.i)) - uv.i = -1; + uv_* restrict_ptr uv = &uv_vec[y * dist.x() + x]; + if (!t.barycentric_coords(vec2(x + min.x(), y + min.y()), uv->coords, uv->i)) + uv->i = -1; } const int ow = tex.width(), oh = tex.height(); @@ -330,14 +330,14 @@ void pose_transform::project_quad_texture() for (int x_ = 0, dx = dist.x(); x_ < dx; x_++) { const int y = y_ + min.y(), x = x_ + min.x(); - uv_ const& restrict_ref uv__ = uv_vec[y_ * dx + x_]; + const uv_* restrict_ptr uv__ = &uv_vec[y_ * dx + x_]; - if (uv__.i != -1) + if (uv__->i != -1) { using uc = unsigned char; - vec2 const& uv = uv__.coords; - int const i = uv__.i; + vec2 const& uv = uv__->coords; + int const i = uv__->i; float fx = origs[i][0].x() + uv.x() * origs[i][2].x() -- cgit v1.2.3