From 40a1fb5c5c98d72e6aa0bd747e5b5d1fe7b2c330 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Fri, 19 Jun 2020 23:16:58 +0200 Subject: [PATCH] Prevent a warning about std::move redundancy (#280) * Prevent a warning about std::move redundancy * Rewrite differently for clang-tidy --- src/sfizz/Macros.h | 2 -- src/sfizz/effects/Apan.cpp | 17 +++++++++-------- src/sfizz/effects/Eq.cpp | 4 +++- src/sfizz/effects/Filter.cpp | 4 +++- src/sfizz/effects/Gain.cpp | 7 ++++--- src/sfizz/effects/Limiter.cpp | 5 +++-- src/sfizz/effects/Lofi.cpp | 9 +++++---- src/sfizz/effects/Rectify.cpp | 11 ++++++----- src/sfizz/effects/Strings.cpp | 9 +++++---- src/sfizz/effects/Width.cpp | 7 ++++--- 10 files changed, 42 insertions(+), 33 deletions(-) diff --git a/src/sfizz/Macros.h b/src/sfizz/Macros.h index 024dfe24..9bd3de39 100644 --- a/src/sfizz/Macros.h +++ b/src/sfizz/Macros.h @@ -10,10 +10,8 @@ #if __cplusplus > 201103L #define CXX14_CONSTEXPR constexpr -#define CXX11_MOVE(x) x #else #define CXX14_CONSTEXPR -#define CXX11_MOVE(x) std::move(x) #endif #if __cplusplus >= 201703L diff --git a/src/sfizz/effects/Apan.cpp b/src/sfizz/effects/Apan.cpp index 473985fd..c21af6c3 100644 --- a/src/sfizz/effects/Apan.cpp +++ b/src/sfizz/effects/Apan.cpp @@ -75,41 +75,42 @@ namespace fx { std::unique_ptr Apan::makeInstance(absl::Span members) { - std::unique_ptr fx { new Apan }; + Apan* apan = new Apan; + std::unique_ptr fx { apan }; for (const Opcode& opc : members) { switch (opc.lettersOnlyHash) { case hash("apan_waveform"): if (auto value = readOpcode(opc.value, Default::apanWaveformRange)) - fx->_lfoWave = *value; + apan->_lfoWave = *value; break; case hash("apan_freq"): if (auto value = readOpcode(opc.value, Default::apanFrequencyRange)) - fx->_lfoFrequency = *value; + apan->_lfoFrequency = *value; break; case hash("apan_phase"): if (auto value = readOpcode(opc.value, Default::apanPhaseRange)) { float phase = *value / 360.0f; phase -= static_cast(phase); - fx->_lfoPhaseOffset = phase; + apan->_lfoPhaseOffset = phase; } break; case hash("apan_dry"): if (auto value = readOpcode(opc.value, Default::apanLevelRange)) - fx->_dry = *value / 100.0f; + apan->_dry = *value / 100.0f; break; case hash("apan_wet"): if (auto value = readOpcode(opc.value, Default::apanLevelRange)) - fx->_wet = *value / 100.0f; + apan->_wet = *value / 100.0f; break; case hash("apan_depth"): if (auto value = readOpcode(opc.value, Default::apanLevelRange)) - fx->_depth = *value / 100.0f; + apan->_depth = *value / 100.0f; break; } } - return CXX11_MOVE(fx); + return fx; } void Apan::computeLfos(float* left, float* right, unsigned nframes) diff --git a/src/sfizz/effects/Eq.cpp b/src/sfizz/effects/Eq.cpp index a61f77e7..1eda27e4 100644 --- a/src/sfizz/effects/Eq.cpp +++ b/src/sfizz/effects/Eq.cpp @@ -92,7 +92,9 @@ namespace fx { } } - return absl::make_unique(desc); + Eq* eq = new Eq(desc); + std::unique_ptr fx { eq }; + return fx; } void Eq::prepareFilter() diff --git a/src/sfizz/effects/Filter.cpp b/src/sfizz/effects/Filter.cpp index 8b118ee0..d39d74f1 100644 --- a/src/sfizz/effects/Filter.cpp +++ b/src/sfizz/effects/Filter.cpp @@ -95,7 +95,9 @@ namespace fx { } } - return absl::make_unique(desc); + Filter* filter = new Filter(desc); + std::unique_ptr fx { filter }; + return fx; } void Filter::prepareFilter() diff --git a/src/sfizz/effects/Gain.cpp b/src/sfizz/effects/Gain.cpp index e5b46acc..04cca832 100644 --- a/src/sfizz/effects/Gain.cpp +++ b/src/sfizz/effects/Gain.cpp @@ -56,17 +56,18 @@ namespace fx { std::unique_ptr Gain::makeInstance(absl::Span members) { - auto fx = absl::make_unique(); + Gain* gain = new Gain; + std::unique_ptr fx { gain }; for (const Opcode& opc : members) { switch (opc.lettersOnlyHash) { case hash("gain"): - setValueFromOpcode(opc, fx->_gain, {-96.0f, 96.0f}); + setValueFromOpcode(opc, gain->_gain, {-96.0f, 96.0f}); break; } } - return CXX11_MOVE(fx); + return fx; } } // namespace fx diff --git a/src/sfizz/effects/Limiter.cpp b/src/sfizz/effects/Limiter.cpp index 70f317d8..9c28ce73 100644 --- a/src/sfizz/effects/Limiter.cpp +++ b/src/sfizz/effects/Limiter.cpp @@ -71,14 +71,15 @@ namespace fx { std::unique_ptr Limiter::makeInstance(absl::Span members) { - auto fx = absl::make_unique(); + Limiter* limiter = new Limiter; + std::unique_ptr fx { limiter }; for (const Opcode& opc : members) { // no opcodes (void)opc; } - return CXX11_MOVE(fx); + return fx; } } // namespace fx diff --git a/src/sfizz/effects/Lofi.cpp b/src/sfizz/effects/Lofi.cpp index 87d64264..12d7759f 100644 --- a/src/sfizz/effects/Lofi.cpp +++ b/src/sfizz/effects/Lofi.cpp @@ -79,20 +79,21 @@ namespace fx { std::unique_ptr Lofi::makeInstance(absl::Span members) { - auto fx = absl::make_unique(); + Lofi* lofi = new Lofi; + std::unique_ptr fx { lofi }; for (const Opcode& opcode : members) { switch (opcode.lettersOnlyHash) { case hash("bitred"): - setValueFromOpcode(opcode, fx->_bitred_depth, { 0.0, 100.0 }); + setValueFromOpcode(opcode, lofi->_bitred_depth, { 0.0, 100.0 }); break; case hash("decim"): - setValueFromOpcode(opcode, fx->_decim_depth, { 0.0, 100.0 }); + setValueFromOpcode(opcode, lofi->_decim_depth, { 0.0, 100.0 }); break; } } - return CXX11_MOVE(fx); + return fx; } /// diff --git a/src/sfizz/effects/Rectify.cpp b/src/sfizz/effects/Rectify.cpp index 1f88a771..56be4682 100644 --- a/src/sfizz/effects/Rectify.cpp +++ b/src/sfizz/effects/Rectify.cpp @@ -83,23 +83,24 @@ namespace fx { std::unique_ptr Rectify::makeInstance(absl::Span members) { - auto fx = absl::make_unique(); + Rectify* rectify = new Rectify; + std::unique_ptr fx { rectify }; for (const Opcode& opc : members) { switch (opc.lettersOnlyHash) { case hash("rectify_mode"): if (opc.value == "full") - fx->_full = true; + rectify->_full = true; else if (opc.value == "half") - fx->_full = false; + rectify->_full = false; break; case hash("rectify"): - setValueFromOpcode(opc, fx->_amount, { 0.0, 100.0 }); + setValueFromOpcode(opc, rectify->_amount, { 0.0, 100.0 }); break; } } - return CXX11_MOVE(fx); + return fx; } } // namespace fx diff --git a/src/sfizz/effects/Strings.cpp b/src/sfizz/effects/Strings.cpp index dfaa0656..9e7295d4 100644 --- a/src/sfizz/effects/Strings.cpp +++ b/src/sfizz/effects/Strings.cpp @@ -126,20 +126,21 @@ namespace fx { std::unique_ptr Strings::makeInstance(absl::Span members) { - auto fx = absl::make_unique(); + Strings* strings = new Strings; + std::unique_ptr fx { strings }; for (const Opcode& opc : members) { switch (opc.lettersOnlyHash) { case hash("strings_number"): - setValueFromOpcode(opc, fx->_numStrings, {0, MaximumNumStrings}); + setValueFromOpcode(opc, strings->_numStrings, {0, MaximumNumStrings}); break; case hash("strings_wet"): - setValueFromOpcode(opc, fx->_wet, {0.0f, 100.0f}); + setValueFromOpcode(opc, strings->_wet, {0.0f, 100.0f}); break; } } - return CXX11_MOVE(fx); + return fx; } } // namespace fx diff --git a/src/sfizz/effects/Width.cpp b/src/sfizz/effects/Width.cpp index f07a9025..52d2876b 100644 --- a/src/sfizz/effects/Width.cpp +++ b/src/sfizz/effects/Width.cpp @@ -63,17 +63,18 @@ namespace fx { std::unique_ptr Width::makeInstance(absl::Span members) { - auto fx = absl::make_unique(); + Width* width = new Width; + std::unique_ptr fx { width }; for (const Opcode& opc : members) { switch (opc.lettersOnlyHash) { case hash("width"): - setValueFromOpcode(opc, fx->_width, {-100.0f, 100.0f}); + setValueFromOpcode(opc, width->_width, {-100.0f, 100.0f}); break; } } - return CXX11_MOVE(fx); + return fx; } } // namespace fx