diff --git a/include/jsoncons/config/compiler_support.hpp b/include/jsoncons/config/compiler_support.hpp index 50889508a..5654f6567 100644 --- a/include/jsoncons/config/compiler_support.hpp +++ b/include/jsoncons/config/compiler_support.hpp @@ -43,16 +43,6 @@ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54577 -#if defined(__clang__) -# define JSONCONS_FALLTHROUGH [[clang::fallthrough]] -#elif defined(__GNUC__) && ((__GNUC__ >= 7)) -# define JSONCONS_FALLTHROUGH __attribute__((fallthrough)) -#elif defined (__GNUC__) -# define JSONCONS_FALLTHROUGH // FALLTHRU -#else -# define JSONCONS_FALLTHROUGH -#endif - #if defined(__GNUC__) || defined(__clang__) #define JSONCONS_LIKELY(x) __builtin_expect(!!(x), 1) #define JSONCONS_UNLIKELY(x) __builtin_expect(!!(x), 0) @@ -414,4 +404,17 @@ namespace jsoncons { JSONCONS_STR( 0 ))); } #endif // _DEBUG +#if defined(JSONCONS_HAS_2017) +# define JSONCONS_FALLTHROUGH [[fallthrough]] +#elif defined(__clang__) +# define JSONCONS_FALLTHROUGH [[clang::fallthrough]] +#elif defined(__GNUC__) && ((__GNUC__ >= 7)) +# define JSONCONS_FALLTHROUGH __attribute__((fallthrough)) +#elif defined (__GNUC__) +# define JSONCONS_FALLTHROUGH // FALLTHRU +#else +# define JSONCONS_FALLTHROUGH +#endif + + #endif // JSONCONS_COMPILER_SUPPORT_HPP diff --git a/include/jsoncons/json_object.hpp b/include/jsoncons/json_object.hpp index 3875d32f9..b947355b5 100644 --- a/include/jsoncons/json_object.hpp +++ b/include/jsoncons/json_object.hpp @@ -518,23 +518,20 @@ namespace jsoncons { void uninitialized_init(index_key_value* items, std::size_t count) { - auto first = items; if (count > 0) { members_.reserve(count); - auto last = first + count; - - std::sort(first, last, compare); - members_.emplace_back(key_type(first->name.c_str(), first->name.size(), get_allocator()), std::move(first->value)); - auto prev_it = first; - for (auto it = first+1; it != last; ++it) + std::sort(items, items+count, compare); + members_.emplace_back(key_type(items[0].name.data(), items[0].name.size(), get_allocator()), std::move(items[0].value)); + + for (std::size_t i = 1; i < count; ++i) { - if (it->name != prev_it->name) + auto& item = items[i]; + if (item.name != items[i-1].name) { - members_.emplace_back(key_type(it->name.c_str(), it->name.size(), get_allocator()), std::move(it->value)); + members_.emplace_back(key_type(item.name.data(), item.name.size(), get_allocator()), std::move(item.value)); } - ++prev_it; } } } @@ -1318,9 +1315,11 @@ namespace jsoncons { std::sort(first, last, compare2); members_.reserve(count); - for (auto it = first; it != last; ++it) + + //for (auto it = first; it != last; ++it) + for (std::size_t i = 0; i < count; ++i) { - members_.emplace_back(std::move(it->name), std::move(it->value)); + members_.emplace_back(std::move(first[i].name), std::move(first[i].value)); } } } diff --git a/include/jsoncons/utility/heap_string.hpp b/include/jsoncons/utility/heap_string.hpp index d89bc0871..d5eb9cb47 100644 --- a/include/jsoncons/utility/heap_string.hpp +++ b/include/jsoncons/utility/heap_string.hpp @@ -70,7 +70,7 @@ namespace utility { Extra extra() const { return this->extra_; } heap_string(Extra extra, const Allocator& alloc) - : heap_string_base(extra, alloc), p_(nullptr), length_(0), offset_(0) + : heap_string_base(extra, alloc), p_(nullptr), length_(0), offset_(0), align_pad_(0) { } diff --git a/include/jsoncons_ext/jsonschema/common/validator.hpp b/include/jsoncons_ext/jsonschema/common/validator.hpp index 1810e72e4..7a9a8464a 100644 --- a/include/jsoncons_ext/jsonschema/common/validator.hpp +++ b/include/jsoncons_ext/jsonschema/common/validator.hpp @@ -172,9 +172,10 @@ namespace jsonschema { } void merge(std::unordered_set&& properties) { - for (auto&& name : properties) + auto end = std::make_move_iterator(properties.end()); + for (auto it = std::make_move_iterator(properties.begin()); it != end; ++it) { - evaluated_properties.insert(std::move(name)); + evaluated_properties.insert(*it); } } void merge(const range_collection& ranges)