@@ -112,16 +112,16 @@ namespace jsoncons {
112112 std::memset (bloom, 0 , bloom_bytes);
113113 for (auto it = first; it != last; ++it)
114114 {
115- auto kv = make_key_value<KeyT,Json>() (*it);
116- uint32_t h = a5hash32 (kv. key () .data (), kv. key () .size (), 0 );
115+ const auto & key = get_key (*it);
116+ uint32_t h = a5hash32 (key.data (), key.size (), 0 );
117117 if (JSONCONS_LIKELY (!bloom_may_contain (bloom, h)))
118118 {
119- data_.emplace_back (std::move (kv ));
119+ data_.emplace_back (key_type (key. begin (), key. end (), get_allocator ()), get_value (*it ));
120120 bloom_set (bloom, h);
121121 }
122122 else
123123 {
124- try_emplace (kv. key (), kv. value ( ));
124+ try_emplace (key_type ( key. begin (), key. end (), get_allocator ()), get_value (*it ));
125125 }
126126 }
127127
@@ -130,8 +130,8 @@ namespace jsoncons {
130130 {
131131 for (auto it = first; it != last; ++it)
132132 {
133- auto kv = make_key_value<KeyT,Json>() (*it);
134- try_emplace (kv. key (), kv. value ( ));
133+ const auto & key = get_key (*it);
134+ try_emplace (key_type ( key. begin (), key. end (), get_allocator ()), get_value (*it ));
135135 }
136136 }
137137 }
@@ -152,16 +152,16 @@ namespace jsoncons {
152152 std::memset (bloom, 0 , bloom_bytes);
153153 for (auto it = first; it != last; ++it)
154154 {
155- auto kv = make_key_value<KeyT,Json>() (*it);
156- uint32_t h = a5hash32 (kv. key () .data (), kv. key () .size (), 0 );
155+ const auto & key = get_key (*it);
156+ uint32_t h = a5hash32 (key.data (), key.size (), 0 );
157157 if (JSONCONS_LIKELY (!bloom_may_contain (bloom, h)))
158158 {
159- data_.emplace_back (std::move (kv ));
159+ data_.emplace_back (key_type (key. begin (), key. end (), get_allocator ()), get_value (*it ));
160160 bloom_set (bloom, h);
161161 }
162162 else
163163 {
164- try_emplace (kv. key (), kv. value ( ));
164+ try_emplace (key_type ( key. begin (), key. end (), get_allocator ()), get_value (*it ));
165165 }
166166 }
167167
@@ -170,8 +170,8 @@ namespace jsoncons {
170170 {
171171 for (auto it = first; it != last; ++it)
172172 {
173- auto kv = make_key_value<KeyT,Json>() (*it);
174- try_emplace (kv. key (), kv. value ( ));
173+ const auto & key = get_key (*it);
174+ try_emplace (key_type ( key. begin (), key. end (), get_allocator ()), get_value (*it ));
175175 }
176176 }
177177 }
@@ -405,6 +405,7 @@ namespace jsoncons {
405405 if (count > 0 )
406406 {
407407 const size_type old_size = size ();
408+ data_.reserve (count);
408409 data_.reserve (old_size+count);
409410 if (old_size+count <= bloom_bytes)
410411 {
@@ -417,25 +418,26 @@ namespace jsoncons {
417418 }
418419 for (auto it = first; it != last; ++it)
419420 {
420- auto kv = make_key_value<KeyT,Json>() (*it);
421- uint32_t h = a5hash32 (kv. key () .data (), kv. key () .size (), 0 );
421+ const auto & key = get_key (*it);
422+ uint32_t h = a5hash32 (key.data (), key.size (), 0 );
422423 if (JSONCONS_LIKELY (!bloom_may_contain (bloom, h)))
423424 {
424- data_.emplace_back (std::move (kv ));
425+ data_.emplace_back (key_type (key. begin (), key. end (), get_allocator ()), get_value (*it ));
425426 bloom_set (bloom, h);
426427 }
427428 else
428429 {
429- try_emplace (kv. key (), kv. value ( ));
430+ try_emplace (key_type ( key. begin (), key. end (), get_allocator ()), get_value (*it ));
430431 }
431432 }
433+
432434 }
433435 else
434436 {
435437 for (auto it = first; it != last; ++it)
436438 {
437- auto kv = make_key_value<KeyT,Json>() (*it);
438- try_emplace (kv. key (), kv. value ( ));
439+ const auto & key = get_key (*it);
440+ try_emplace (key_type ( key. begin (), key. end (), get_allocator ()), get_value (*it ));
439441 }
440442 }
441443 }
@@ -446,7 +448,8 @@ namespace jsoncons {
446448 {
447449 for (auto it = first; it != last; ++it)
448450 {
449- data_.emplace_back (make_key_value<KeyT,Json>()(*it));
451+ const auto & key = get_key (*it);
452+ data_.emplace_back (key_type (key.begin (), key.end (),get_allocator ()), get_value (*it));
450453 }
451454 }
452455
0 commit comments