Skip to content

Commit c078957

Browse files
committed
Remove unnecessary universal references
1 parent cf084ae commit c078957

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

src/ArduinoJson/Array/ArrayData.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class ArrayData : public CollectionData {
1919
}
2020

2121
template <typename T>
22-
bool addValue(T&& value, ResourceManager* resources);
22+
bool addValue(const T& value, ResourceManager* resources);
2323

2424
template <typename T>
25-
static bool addValue(ArrayData* array, T&& value,
25+
static bool addValue(ArrayData* array, const T& value,
2626
ResourceManager* resources) {
2727
if (!array)
2828
return false;

src/ArduinoJson/Array/ArrayImpl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ inline void ArrayData::removeElement(size_t index, ResourceManager* resources) {
5757
}
5858

5959
template <typename T>
60-
inline bool ArrayData::addValue(T&& value, ResourceManager* resources) {
60+
inline bool ArrayData::addValue(const T& value, ResourceManager* resources) {
6161
ARDUINOJSON_ASSERT(resources != nullptr);
6262
auto slot = resources->allocVariant();
6363
if (!slot)
6464
return false;
6565
JsonVariant variant(slot.ptr(), resources);
66-
if (!variant.set(detail::forward<T>(value))) {
66+
if (!variant.set(value)) {
6767
resources->freeVariant(slot);
6868
return false;
6969
}

src/ArduinoJson/Variant/VariantData.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,13 @@ class VariantData {
119119
}
120120

121121
template <typename T>
122-
bool addValue(T&& value, ResourceManager* resources) {
122+
bool addValue(const T& value, ResourceManager* resources) {
123123
auto array = isNull() ? &toArray() : asArray();
124-
return detail::ArrayData::addValue(array, detail::forward<T>(value),
125-
resources);
124+
return detail::ArrayData::addValue(array, value, resources);
126125
}
127126

128127
template <typename T>
129-
static bool addValue(VariantData* var, T&& value,
128+
static bool addValue(VariantData* var, const T& value,
130129
ResourceManager* resources) {
131130
if (!var)
132131
return false;

src/ArduinoJson/Variant/VariantRefBase.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,19 +297,18 @@ class VariantRefBase : public VariantTag {
297297
}
298298

299299
template <typename TConverter, typename T>
300-
bool doSet(T&& value) const {
300+
bool doSet(const T& value) const {
301301
return doSet<TConverter>(
302-
detail::forward<T>(value),
303-
is_same<typename function_traits<
304-
decltype(&TConverter::toJson)>::return_type,
305-
bool>{});
302+
value, is_same<typename function_traits<
303+
decltype(&TConverter::toJson)>::return_type,
304+
bool>{});
306305
}
307306

308307
template <typename TConverter, typename T>
309-
bool doSet(T&& value, false_type) const;
308+
bool doSet(const T& value, false_type) const;
310309

311310
template <typename TConverter, typename T>
312-
bool doSet(T&& value, true_type) const;
311+
bool doSet(const T& value, true_type) const;
313312

314313
ArduinoJson::JsonVariant getOrCreateVariant() const;
315314
};

src/ArduinoJson/Variant/VariantRefBaseImpl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ VariantRefBase<TDerived>::operator[](const TString& key) const {
140140

141141
template <typename TDerived>
142142
template <typename TConverter, typename T>
143-
inline bool VariantRefBase<TDerived>::doSet(T&& value, false_type) const {
143+
inline bool VariantRefBase<TDerived>::doSet(const T& value, false_type) const {
144144
TConverter::toJson(value, getOrCreateVariant());
145145
auto resources = getResourceManager();
146146
return resources && !resources->overflowed();
147147
}
148148

149149
template <typename TDerived>
150150
template <typename TConverter, typename T>
151-
inline bool VariantRefBase<TDerived>::doSet(T&& value, true_type) const {
151+
inline bool VariantRefBase<TDerived>::doSet(const T& value, true_type) const {
152152
return TConverter::toJson(value, getOrCreateVariant());
153153
}
154154

0 commit comments

Comments
 (0)