2339 Commits

Author SHA1 Message Date
Hendrik Muhs
3168d7c343 add a test that provokes a compile time error on windows 2021-04-18 18:06:35 +02:00
Milo Yip
47b837e14a
Merge pull request #1485 from ylavic/MemberMap
Object members stored in std::multimap
2021-04-08 10:06:28 +08:00
ylavic
be4a5a9087 Turn some Tests to RAPIDJSON_USE_MEMBERSMAP in CI. 2021-04-07 18:22:46 +02:00
ylavic
fc08f4f61b Tests for Members in std::multimap. 2021-04-07 18:22:46 +02:00
ylavic
71f0fa7eb3 Set RAPIDJSON_USE_MEMBERSMAP to use a (std::multi)map for object members.
When RAPIDJSON_USE_MEMBERSMAP is defined, an object Value will store
its members in an (re)allocated array of Members like before, but also
in an std::multimap<GenericValue::Data,SizeType> where the key and value
reference the corresponding Member by its Data and index in the array,
respectively, and in a relocatable manner.

The layout of the members map/array is now:
 {multimap*}<>{capacity}<>{Member[capacity]}<>{multimap::iterator[capacity]}
where <> stands for the RAPIDJSON_ALIGN-ment of each part, if needed.

This layout needs to be reallocated when the current capacity is
exhausted, which requires to take care of the multimap and its iterators
explicitely. The multimap is allocated separately and only its pointer is
saved in this layout, so it can easily be restored in its new position.
As for the old/alive iterators, they must move to their new offset according
to the new capacity.

With this in place, it's immediate to get the multimap::iterator from a
MemberIterator and vice versa, thus the same complexity applies for the
operations with MemberIterator or MapIterator.

For FindMember() and RemoveMember(), the complexity drops from O(n) to
the multimap/rbtree's O(log n).
For EraseMember() it drops from O(n-m) to O((log n)-m), m representing
the move/copy of the trailing members.
For AddMember() though, the complexity grows from O(1) to O(log n) due to
the insertion in the multimap too.

Consequently parsing will be slower, up to ~20% measured in perftests on
my laptop (since it's mainly composed of insertions). But later work on
the Document (usually the goal of parsing...) will be much faster; the
new DocumentFind perftest included in this commit is 8 times faster with
RAPIDJSON_USE_MEMBERSMAP (still on my laptop). Overall the tests are 4%
slower (mainly composed of parsing), and notably 15% slower for schemas
parsing/validation (which supposedly comes from the larger JSON files
parsing, still). As a side note, when RAPIDJSON_USE_MEMBERSMAP is not
defined, this commit does nothing (same results for perftest with regard
to previous versions).

Finally, the multimap is allocated and constructed using StdAllocator,
so they will use the same Allocator than for any other Value allocation,
and thus will benefit from the same performance/safety/security/whatever
provided by the user given Allocator.
2021-04-07 18:22:46 +02:00
Milo Yip
7d801bbe45
Merge pull request #1503 from ylavic/sub_value_assignment
Fix (Sub-)Value assignment
2021-04-07 17:52:51 +08:00
Milo Yip
03676c9bf5
Merge pull request #1870 from ylavic/allocators_rvalues
Add rvalue copy and assignment to MemoryPoolAllocator and StdAllocator.
2021-04-07 17:39:26 +08:00
ylavic
aa0675ffd7 Try some tests with -D_GLIBCXX_DEBUG and coverage with -O0. 2021-04-04 12:51:47 +02:00
ylavic
5c764d9a81 Tests for Allocators copy by rvalue reference. 2021-04-04 12:51:47 +02:00
ylavic
683010b02d Add rvalue copy and assignment to MemoryPoolAllocator and StdAllocator. 2021-04-04 12:51:47 +02:00
ylavic
117276c413 Fix would-crash tests if the default allocator used were kNeedFree.
The allocator cannot be destroyed before the Document, otherwise the
Value destructor double frees.
2021-04-02 21:09:20 +02:00
Milo Yip
49aa0fc15d
Merge pull request #1868 from ylavic/cpp17_in_ci
Handle C++17 (and C++11 with MSVC) in CI.
2021-04-01 14:40:55 +08:00
ylavic
a8bd931766 Tests for C++17 with VS 2019. 2021-03-30 15:58:17 +02:00
ylavic
6bed9b266f Don't define StdAllocator<void> from C++17. 2021-03-30 13:47:04 +02:00
ylavic
e336667b4a Handle C++17 (and C++11 with MSVC) in CI. 2021-03-30 10:12:36 +02:00
Milo Yip
b996a23714
Merge pull request #1866 from ylavic/std_allocator_traits
Make StdAllocator C++17-20 compatible.
2021-03-30 14:31:29 +08:00
ylavic
08cf9a56c0 Make StdAllocator C++17-20 compatible. 2021-03-29 11:32:33 +02:00
ylavic
02f42604bd Make StdAllocator C++17-20 compatible. 2021-03-28 23:48:14 +02:00
Milo Yip
cd5ee4dfe9
Merge pull request #1858 from ylavic/std_allocator
Provide StdAllocator, STL compatible, for use with standard types
2021-03-25 15:22:32 +08:00
miloyip
3d77d11e28 add traverse as pointer example 2021-03-24 16:51:12 +08:00
ylavic
2e6f761458 Tests for StdAllocator. 2021-03-16 01:03:04 +01:00
ylavic
49e4dd619f Provide StdAllocator, STL compatible, for use with STL types. 2021-03-16 01:03:04 +01:00
ylavic
50cb424c34 Test assignment from inner Value. 2021-03-15 23:57:42 +01:00
ylavic
c033292aea Safer GenericValue& operator=(GenericValue& rhs).
When rhs is a sub-Value of *this, destroying *this also destroys/frees
rhs, thus the following RawAssign(rhs) crashes.

Address this by saving/moving rhs to a temporary first, which clears rhs
and avoids its destruction with *this.

The crash can be reproduced in test Value.MergeDuplicateKey by using the
CrtAllocator instead of the default Document's MemoryPoolAllocator.
2021-03-15 23:57:42 +01:00
ylavic
d51dd2d0e9 RAPIDJSON_NOEXCEPT_ASSERT should assert regardless of RAPIDJSON_HAS_CXX11_NOEXCEPT. 2021-03-12 15:32:17 +01:00
ylavic
cdb2d4757d Provide RAPIDJSON_HAS_CXX11 and use it for RAPIDJSON_HAS_CXX11_RVALUE_REFS and RAPIDJSON_HAS_CXX11_NOEXCEPT. 2021-03-12 15:14:30 +01:00
miloyip
1c2c8e085a doc: fix incorrect template parameters in EncodedOutputStream example
Fix #1851
2021-03-02 11:15:31 +08:00
Milo Yip
b1a4d91a53
Merge pull request #1779 from pavel-pimenov/fix-1778-part-1
fix 1778  (part 1)
2021-02-23 10:23:34 +08:00
Milo Yip
8be64594f2
Merge pull request #1847 from stac47/fix_1846
Fix recursive operator== call in C++20 (#1846)
2021-02-23 10:21:11 +08:00
Laurent Stacul
24ebd51287 Fix recursive operator== call in C++20 (#1846) 2021-02-22 16:52:27 +00:00
Milo Yip
8bce684cda
Merge pull request #1844 from smhdfdl/multiple-validation-failures-and-validation-messages
After PR 1837, fix crash where simple type with sub-schema has a bad value
2021-02-22 00:01:56 +08:00
Steve Hanson
9bb81e20ff fix crash where simple type with sub-schema has a bad value 2021-02-12 17:36:55 +00:00
Milo Yip
13dfc96c9c
Merge pull request #1837 from smhdfdl/multiple-validation-failures-and-validation-messages
Fixes for issues #1835 & #1836 - Multiple validation failures and readable validation messages
2021-02-03 21:19:27 +08:00
Steve Hanson
167efb4fa0 work around issue 1089 2021-02-03 08:34:10 +00:00
Steve Hanson
28dc42d8d3 restore coverage 2021-01-29 19:20:01 +00:00
Steve Hanson
a3757456fe correct workaround for issue 1805 2021-01-29 16:43:12 +00:00
Steve Hanson
7fee368be3 Revert "revert perftest"
This reverts commit 221e8d5364d817f3ea89ec0e124e2fa68a696952.
2021-01-29 11:58:31 +00:00
Steve Hanson
221e8d5364 revert perftest 2021-01-29 11:38:33 +00:00
Steve Hanson
f89e75af75 remove C++ 11 std::string to_string() syntax 2021-01-29 11:08:01 +00:00
Steve Hanson
c491dd5213 remove C++ 11 enum syntax 2021-01-29 10:26:05 +00:00
Steve Hanson
6f3cccd6e1 remove debug std::cout, handle empty error object in example 2021-01-28 14:21:36 +00:00
Steve Hanson
05e7b33977 code and tests 2021-01-28 12:11:43 +00:00
Steve Hanson
5d17b24e53
Merge pull request #1 from Tencent/master
PR for commits 2021/01/12
2021-01-12 14:54:16 +00:00
Milo Yip
585042c02b
Merge pull request #1821 from slsyy/master
Add implicit conversion from Object and Array to Value (#1404)
2021-01-06 13:43:21 +08:00
Krystian Chmura
cbf62de55d Add implicit conversion from Object and Array to Value (#1404)
Allows resolution of JSON Pointer on Object and Array
2021-01-05 14:20:57 +01:00
Milo Yip
3cdd3c8370
Merge pull request #1817 from lukedan/lukedan_cpp20
Fix #1721
2020-12-28 10:32:35 +08:00
Xuanyi Zhou
5e50f27ed1 also initialize class member 2020-12-26 23:41:42 -05:00
Xuanyi Zhou
1e4f59d3ae add return statement & comment 2020-12-26 23:38:27 -05:00
Xuanyi Zhou
d742a030aa add body to private copy constructor & copy assignment 2020-12-26 23:27:43 -05:00
Xuanyi Zhou
3006926231 suppress enum bitwise operation warnings on msvc 2020-12-26 23:09:39 -05:00