2368 Commits

Author SHA1 Message Date
Steve Hanson
a21cf9f7b8 equiv fix for issue 1899 2021-06-14 11:35:00 +01:00
Steve Hanson
12b88efa6f fix coverage again 2021-06-09 18:11:04 +01:00
Steve Hanson
f6ebcb2008 fix Uri.Match optional arg 2021-06-09 16:38:40 +01:00
Steve Hanson
3df804c128 fix coverage, unit test allocators and equality 2021-06-09 10:31:09 +01:00
Steve Hanson
18ab3b16bc remove temp debug statements 2021-06-08 17:11:42 +01:00
Steve Hanson
6d253c160d remove compiler warning 2021-06-08 15:31:25 +01:00
Steve Hanson
28bcbd3f35 make std::string optional 2021-06-08 10:53:10 +01:00
Steve Hanson
494447b731 remove copyright & debug statements 2021-05-21 15:55:11 +01:00
Steve Hanson
6e58a53f44 fix coverage 2021-05-20 17:44:34 +01:00
Steve Hanson
3987d82f41 Merge branch 'master' of https://github.com/Tencent/rapidjson into id-and-ref 2021-05-20 12:20:12 +01:00
Milo Yip
17aa824c92
Merge pull request #1885 from saurabhchardereal/master
Improve documentation
2021-05-07 17:00:48 +08:00
Saurabh Charde
cd737fb545
Improve documentation
Signed-off-by: Saurabh Charde <saurabhchardereal@gmail.com>
2021-05-07 14:13:33 +05:30
Milo Yip
25fa7a119d
Merge pull request #1883 from nkolotov/fix/issues/1882
Fixed -Wshadow warning.
2021-05-06 09:54:52 +08:00
N. Kolotov
3aa8d04b74 Fixed -Wshadow warning. 2021-05-03 01:56:41 +03:00
Milo Yip
e0f68a4356
Merge pull request #1877 from hendrikmuhs/windows-GetObject-conflict-#1418
add a workaround for GetObject macro defined by windows.h
2021-04-20 10:02:53 +08:00
Hendrik Muhs
3cdfde14d6 replace auto with concrete type 2021-04-19 13:15:11 -07:00
Hendrik Muhs
d179facf90 don't let the GetObject macro rewrite the GetObject method, add a GetObj alias 2021-04-19 12:29:11 -07:00
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
Steve Hanson
bc026e3fb5 satisfy all compilers 3 2021-03-11 18:25:10 +00:00
Steve Hanson
24b9b7e276 satisfy all compilers 2 2021-03-11 18:16:24 +00:00
Steve Hanson
32722fa31d satisfy all compilers 2021-03-11 16:53:05 +00:00
Steve Hanson
8768b5b1d6 correct #defines in uri.h 2021-03-11 15:13:17 +00:00
Steve Hanson
6c9da69abf remove comma 2021-03-11 15:06:02 +00:00
Steve Hanson
6b57738e4a handle internal refs properly 2021-03-11 14:49:28 +00:00
miloyip
1c2c8e085a doc: fix incorrect template parameters in EncodedOutputStream example
Fix #1851
2021-03-02 11:15:31 +08:00