diff options
| -rw-r--r-- | compat/mutex.hpp | 1 | ||||
| -rw-r--r-- | compat/sleep.cpp | 2 | ||||
| -rw-r--r-- | dinput/dinput.hpp | 14 | ||||
| -rw-r--r-- | filter-accela/accela-settings.hpp | 8 | ||||
| -rw-r--r-- | filter-accela/ftnoir_filter_accela.cpp | 10 | ||||
| -rw-r--r-- | logic/main-settings.cpp | 6 | ||||
| -rw-r--r-- | options/base-value.cpp | 11 | ||||
| -rw-r--r-- | options/base-value.hpp | 8 | ||||
| -rw-r--r-- | options/bundle.cpp | 4 | ||||
| -rw-r--r-- | options/group.cpp | 10 | 
10 files changed, 27 insertions, 47 deletions
| diff --git a/compat/mutex.hpp b/compat/mutex.hpp index e4d0fee6..54758a08 100644 --- a/compat/mutex.hpp +++ b/compat/mutex.hpp @@ -16,6 +16,7 @@ public:      mutex& operator=(const mutex& datum);      mutex(const mutex& datum);      explicit mutex(RecursionMode m); +    mutex() : mutex{NonRecursive} {}      QMutex* operator&() const noexcept;      explicit operator QMutex*() const noexcept; diff --git a/compat/sleep.cpp b/compat/sleep.cpp index 5178ae2f..e64e6254 100644 --- a/compat/sleep.cpp +++ b/compat/sleep.cpp @@ -14,7 +14,7 @@ namespace portable          {  #ifdef _WIN32 -            Sleep(milliseconds); +            Sleep((unsigned)milliseconds);  #else              usleep(unsigned(milliseconds) * 1000U); // takes microseconds  #endif diff --git a/dinput/dinput.hpp b/dinput/dinput.hpp index 4bb3b458..9dbc576c 100644 --- a/dinput/dinput.hpp +++ b/dinput/dinput.hpp @@ -36,16 +36,6 @@ public:      di_t& operator=(const di_t&) = default;      diptr operator->() const { return handle; } -    operator bool() { return handle != nullptr; } - -    // for debugging bad usages. must use a dependent name. -    template<typename t = void> -    explicit operator void*() const -    { -        static_assert(sizeof(t) == -1); -        static_assert(sizeof(t) == 0); - -        return nullptr; -    } +    operator bool() const { return handle != nullptr; } +    operator diptr() const { return handle; }  }; - diff --git a/filter-accela/accela-settings.hpp b/filter-accela/accela-settings.hpp index ce27f800..c873b0b4 100644 --- a/filter-accela/accela-settings.hpp +++ b/filter-accela/accela-settings.hpp @@ -1,8 +1,8 @@  #pragma once +#include "spline/spline.hpp"  #include "options/options.hpp"  using namespace options; -#include "spline/spline.hpp"  // ------------------------------------  // debug knobs @@ -19,8 +19,7 @@ struct settings_accela : opts          double x, y;      }; -    static constexpr inline gains const rot_gains[16] = -    { +    static constexpr gains const rot_gains[] {          { 9, 300 },          { 8, 200 },          { 5, 100 }, @@ -30,8 +29,7 @@ struct settings_accela : opts          { .5, .4 },      }; -    static constexpr inline gains const pos_gains[16] = -    { +    static constexpr gains const pos_gains[] {          { 9, 200 },          { 8, 150 },          { 7, 110 }, diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index 9e973586..3795a8f0 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -20,10 +20,12 @@ accela::accela()      s.make_splines(spline_rot, spline_pos);  } -template<int N = 3, typename F> +template<typename F>  cc_noinline  static void do_deltas(const double* deltas, double* output, F&& fun)  { +    constexpr unsigned N = 3; +      double norm[N];      double dist = 0; @@ -40,17 +42,17 @@ static void do_deltas(const double* deltas, double* output, F&& fun)      }      double n = 0; -    for (unsigned k = 0; k < N; k++) +    for (unsigned k = 0; k < N; k++) // NOLINT(modernize-loop-convert)          n += norm[k];      if (n > 1e-6)      {          const double ret = 1./n; -        for (unsigned k = 0; k < N; k++) +        for (unsigned k = 0; k < N; k++) // NOLINT(modernize-loop-convert)              norm[k] *= ret;      }      else -        for (unsigned k = 0; k < N; k++) +        for (unsigned k = 0; k < N; k++) // NOLINT(modernize-loop-convert)              norm[k] = 0;      for (unsigned k = 0; k < N; k++) diff --git a/logic/main-settings.cpp b/logic/main-settings.cpp index 19bb692d..3865e602 100644 --- a/logic/main-settings.cpp +++ b/logic/main-settings.cpp @@ -17,9 +17,9 @@ key_opts& key_opts::operator=(const key_opts& x)  {      if (&x != this)      { -        keycode = *x.keycode; -        guid = *x.guid; -        button = *x.button; +        keycode = x.keycode; +        guid = x.guid; +        button = x.button;      }      return *this; diff --git a/options/base-value.cpp b/options/base-value.cpp index 39453a09..d4ec4b6c 100644 --- a/options/base-value.cpp +++ b/options/base-value.cpp @@ -12,14 +12,3 @@ value_::~value_()  {      b->on_value_destructed(this);  } - -namespace options::detail { - -// necessary due to circular dependency -void set_value_to_default(value_* val) -{ -    val->set_to_default(); -} - -} // ns options::detail - diff --git a/options/base-value.hpp b/options/base-value.hpp index 7a3ac420..240cc6b7 100644 --- a/options/base-value.hpp +++ b/options/base-value.hpp @@ -63,7 +63,8 @@ protected:      bundle b;      QString self_name; -    virtual void store_variant(const QVariant& x) noexcept = 0; +    virtual void store_variant(QVariant&&) noexcept = 0; +    virtual void store_variant(const QVariant&) noexcept = 0;      template<typename t>      void store_(const t& datum) @@ -89,10 +90,9 @@ public slots:      OTR_OPTIONS_SLOT(const QList<slider_value>&)      OTR_OPTIONS_SLOT(const QList<QPointF>&) -    virtual void set_to_default() = 0; +    virtual void set_to_default() noexcept = 0;      virtual void notify() const = 0; - -    friend void ::options::detail::set_value_to_default(value_* val); +    virtual QVariant get_variant() const noexcept = 0;  };  } //ns options diff --git a/options/bundle.cpp b/options/bundle.cpp index 938639b3..6b7ccce1 100644 --- a/options/bundle.cpp +++ b/options/bundle.cpp @@ -35,10 +35,6 @@ void bundle::reload()      {          QMutexLocker l(&mtx); -        // XXX what do we do when values are and aren't equal? -        // see QPointF -sh 20180830 - -        // XXX we could probably skip assigning to `saved' -sh 20180830          saved = group(group_name);          transient = saved; diff --git a/options/group.cpp b/options/group.cpp index af66aaf2..8a0eeb03 100644 --- a/options/group.cpp +++ b/options/group.cpp @@ -22,7 +22,11 @@ using namespace options::globals;  group::group(const QString& name) : name(name)  { -    if (name == "") +    constexpr unsigned reserved_buckets = 64; +    kvs.reserve(reserved_buckets); +    kvs.max_load_factor(0.4375); + +    if (name.isEmpty())          return;      with_settings_object([&](QSettings& conf) { @@ -35,7 +39,7 @@ group::group(const QString& name) : name(name)  void group::save() const  { -    if (name == "") +    if (name.isEmpty())          return;      with_settings_object([&](QSettings& s) { @@ -63,7 +67,7 @@ QVariant group::get_variant(const QString& name) const      if (it != kvs.cend())          return it->second; -    return QVariant(); +    return {};  }  } // ns options::detail | 
