diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 5464fa919..9b8c60af5 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -123,7 +123,6 @@ class input_stream_adapter }; #endif // JSON_NO_IO - // General-purpose iterator-based adapter. It might not be as fast as // theoretically possible for some containers, but it is extremely versatile. template @@ -133,12 +132,11 @@ class iterator_input_adapter using char_type = typename std::iterator_traits::value_type; iterator_input_adapter(IteratorType first, IteratorType last) - : current(std::move(first)), end(std::move(last)), current_has_been_consumed(false) + : current(std::move(first)), end(std::move(last)) {} typename std::char_traits::int_type get_character() { - if (JSON_HEDLEY_LIKELY(current_has_been_consumed)) { std::advance(current, 1); @@ -149,18 +147,15 @@ class iterator_input_adapter current_has_been_consumed = true; return std::char_traits::to_int_type(*current); } - else - { - current_has_been_consumed = false; - return std::char_traits::eof(); - } + current_has_been_consumed = false; + return std::char_traits::eof(); } private: mutable IteratorType current; const IteratorType end; - mutable bool current_has_been_consumed; + mutable bool current_has_been_consumed = false; template friend struct wide_string_input_helper; @@ -309,7 +304,7 @@ class wide_string_input_adapter using char_type = char; wide_string_input_adapter(BaseInputAdapter base) - : base_adapter(base) {} + : base_adapter(std::move(base)) {} typename std::char_traits::int_type get_character() noexcept { diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index c39bf7a09..8315fec60 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -5834,7 +5834,6 @@ class input_stream_adapter }; #endif // JSON_NO_IO - // General-purpose iterator-based adapter. It might not be as fast as // theoretically possible for some containers, but it is extremely versatile. template @@ -5844,12 +5843,11 @@ class iterator_input_adapter using char_type = typename std::iterator_traits::value_type; iterator_input_adapter(IteratorType first, IteratorType last) - : current(std::move(first)), end(std::move(last)), current_has_been_consumed(false) + : current(std::move(first)), end(std::move(last)) {} typename std::char_traits::int_type get_character() { - if (JSON_HEDLEY_LIKELY(current_has_been_consumed)) { std::advance(current, 1); @@ -5860,18 +5858,15 @@ class iterator_input_adapter current_has_been_consumed = true; return std::char_traits::to_int_type(*current); } - else - { - current_has_been_consumed = false; - return std::char_traits::eof(); - } + current_has_been_consumed = false; + return std::char_traits::eof(); } private: mutable IteratorType current; const IteratorType end; - mutable bool current_has_been_consumed; + mutable bool current_has_been_consumed = false; template friend struct wide_string_input_helper; @@ -6020,7 +6015,7 @@ class wide_string_input_adapter using char_type = char; wide_string_input_adapter(BaseInputAdapter base) - : base_adapter(base) {} + : base_adapter(std::move(base)) {} typename std::char_traits::int_type get_character() noexcept {