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. --- filter-accela/accela-settings.hpp | 4 ++-- filter-accela/ftnoir_filter_accela.cpp | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'filter-accela') diff --git a/filter-accela/accela-settings.hpp b/filter-accela/accela-settings.hpp index 2fea2f33..63173aa8 100644 --- a/filter-accela/accela-settings.hpp +++ b/filter-accela/accela-settings.hpp @@ -19,7 +19,7 @@ struct settings_accela : opts double x, y; }; - static constexpr gains rot_gains[16] = + static constexpr inline gains const rot_gains[16] = { { 9, 300 }, { 8, 200 }, @@ -30,7 +30,7 @@ struct settings_accela : opts { .5, .4 }, }; - static constexpr gains pos_gains[16] = + static constexpr inline gains const pos_gains[16] = { { 9, 200 }, { 8, 150 }, diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index fc660d2c..23d71ef0 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -14,9 +14,6 @@ #include "compat/math-imports.hpp" -constexpr settings_accela::gains settings_accela::rot_gains[16]; -constexpr settings_accela::gains settings_accela::pos_gains[16]; - accela::accela() : first_run(true) { s.make_splines(spline_rot, spline_pos); -- cgit v1.2.3