1010template <class T >
1111crow::json::wvalue list_to_json (const std::vector<T> &array) {
1212 crow::json::wvalue::list l;
13- for (auto item : array)
13+ for (const auto & item : array) {
1414 l.push_back (item.to_json ());
15- return crow::json::wvalue (l);
15+ }
16+ return {l};
1617}
1718
1819crow::json::wvalue list_to_json (const std::vector<unsigned int > &array) {
1920 crow::json::wvalue::list l;
20- for (auto item : array)
21- l.push_back (item);
22- return crow::json::wvalue (l);
21+ for (auto item : array) {
22+ l.emplace_back (item);
23+ }
24+ return {l};
2325}
2426
2527crow::json::wvalue PublicKey::to_json () const {
@@ -35,7 +37,7 @@ crow::json::wvalue WeightedUrl::to_json() const {
3537 crow::json::wvalue w (weight);
3638
3739 l.push_back (w);
38- l.push_back (url);
40+ l.emplace_back (url);
3941 return l;
4042}
4143
@@ -171,15 +173,15 @@ RequestMKCs::from_string(const std::string &str) {
171173 if (denominations.t () != crow::json::type::List) {
172174 return tl::make_unexpected (eError::JSON_WRONG_REQUEST_TYPE);
173175 } else {
174- for (auto d : denominations.lo ()) {
176+ for (const auto & d : denominations.lo ()) {
175177 r.denominations .push_back (d.u ());
176178 }
177179 }
178180 auto mint_key_ids = json[" mint_key_ids" ];
179181 if (mint_key_ids.t () != crow::json::type::List) {
180182 return tl::make_unexpected (eError::JSON_WRONG_REQUEST_TYPE);
181183 } else {
182- for (auto k: mint_key_ids.lo ()) {
184+ for (const auto & k: mint_key_ids.lo ()) {
183185 auto kv = BigInt::from_string (k.s ());
184186 if (!kv.has_value ()) {
185187 return tl::make_unexpected (eError::JSON_PARSE_ERROR);
@@ -269,7 +271,7 @@ RequestMint::from_string(const std::string &str) {
269271 return tl::make_unexpected (eError::JSON_WRONG_VALUE_TYPE);
270272 }
271273
272- for (auto item : json[" blinds" ]) {
274+ for (const auto & item : json[" blinds" ]) {
273275 auto b = Blind::from_json (item);
274276 if (!b.has_value ()) {
275277 return tl::make_unexpected (b.error ());
@@ -384,7 +386,7 @@ RequestRenew::from_string(const std::string &str) {
384386 } else {
385387 RequestRenew r;
386388
387- for (auto item : json[" coins" ]) {
389+ for (const auto & item : json[" coins" ]) {
388390 auto coin = Coin::from_json (item);
389391 if (!coin.has_value ()) {
390392 return tl::make_unexpected (coin.error ());
@@ -393,7 +395,7 @@ RequestRenew::from_string(const std::string &str) {
393395 }
394396 }
395397
396- for (auto item : json[" blinds" ]) {
398+ for (const auto & item : json[" blinds" ]) {
397399 auto blind = Blind::from_json (item);
398400 if (!blind.has_value ()) {
399401 return tl::make_unexpected (blind.error ());
@@ -453,7 +455,7 @@ RequestRedeem::from_string(const std::string &str) {
453455 return tl::make_unexpected (eError::JSON_WRONG_VALUE_TYPE);
454456 }
455457
456- for (auto item : json[" coins" ]) {
458+ for (const auto & item : json[" coins" ]) {
457459 auto coin = Coin::from_json (item);
458460 if (!coin.has_value ()) {
459461 return tl::make_unexpected (coin.error ());
0 commit comments