599 Commits

Author SHA1 Message Date
Sean Leather
4ded1f44f4 Use predefined macros to enable SSE with gmake 2014-10-17 22:44:07 +02:00
Milo Yip
98f87905d9 Update tutorial.md
Correct `PushBack()` example
2014-09-26 11:32:25 +08:00
Milo Yip
a2354cd745 Merge pull request #154 from gadomski/doc-typo
Fix small typo in the docs
2014-09-24 18:41:32 +08:00
Pete Gadomski
c7efabc0cf Fix small typo in the docs 2014-09-24 06:25:58 -04:00
Milo Yip
42de1ce260 Merge pull request #150 from TyRoXx/conversion_warnings
turn implicit integer conversions into static_casts to avoid warnings
2014-09-18 09:29:36 +08:00
TyRoXx
b9608f2cf2 turn implicit integer conversions into static_casts to avoid -Wconversion warnings 2014-09-17 20:30:19 +02:00
Milo Yip
ca9b2d188f Merge pull request #148 from pah/fixes/solaris
Alternative compilation fix for Solaris
2014-09-16 18:41:26 +08:00
Philipp A. Hartmann
5117f9e555 explicitly qualify C(++) library functions
Some compilers do not export the standard C library functions
to the global namespace, in case the C++ header variants are
included (<cstdlib>, <cstring>).

RapidJSON currently uses:
 * malloc, realloc, free
 * memcpy, memmove, memset, memcpy

Add an explicit namespace qualification to avoid lookup problems.
2014-09-16 10:42:14 +02:00
Philipp A. Hartmann
c0bde81b03 rapidjson.h: explicitly import std::size_t to rapidjson namespace 2014-09-16 10:37:37 +02:00
Philipp A. Hartmann
e052c727b2 GenericValue: drop forced packing pragma 2014-09-16 10:19:40 +02:00
Milo Yip
2475e9524b Merge pull request #140 from kojik1010/mempool_null_check
make MemoryPoolAllocator's Malloc work after Clear if a buffer was not supplied by the user
2014-09-11 16:52:36 +08:00
Koji Kobayashi
a69dffbc53 make MemoryPoolAllocator's Malloc work after Clear if a buffer was not supplied by the user 2014-09-10 20:35:23 -07:00
Milo Yip
a5ffc5be1c Merge pull request #139 from pah/fixes/stack-growth-factor
Stack: adjust growth factor
2014-09-09 19:18:30 +08:00
Philipp A. Hartmann
296c7db140 Stack: adjust growth factor
The growth factor for the `internal::Stack` helper has not been updated
together with the growth factors used in GenericValue (#130).
2014-09-09 10:49:40 +02:00
Milo Yip
7cca533971 Update readme.md 2014-09-09 14:05:57 +08:00
miloyip
d0f98d2da1 Fix a bug in dtoa on gcc
Discovered in https://github.com/miloyip/dtoa-benchmark/issues/1 with
assertion fail.
2014-09-07 15:20:09 +08:00
Milo Yip
c4a1566a4e Merge pull request #136 from Kosta-Github/Kosta/doc_key_method
fix `SAX` documentation to also mention the new `Key()` method in the `Handler` concept
2014-09-05 17:08:54 +08:00
Kosta
8e624133bb fix SAX documentation to also mention the new Key() method in the Handler concept 2014-09-05 10:33:20 +02:00
Milo Yip
5e03cbf1b3 Merge pull request #134 from Kosta-Github/Kosta/add_key_method
add `Key()` method to the `Handler` concept
2014-09-05 09:50:24 +08:00
Kosta
f0d9ab4ec9 finally fixing Reader::ParseString()
It was a copy-n-paste error for the last argument of `Key()` and `String()`...
2014-09-04 18:00:05 +02:00
Kosta
00ac1024ee more changes 2014-09-04 17:37:13 +02:00
Kosta
e70494bc00 fix for Reader::ParseString() implementation plus some minor code cleanups and additions 2014-09-04 17:29:52 +02:00
Kosta
4a71dc6d58 reunified ParseKey, ParseString, and ParseStringOrKey again 2014-09-04 16:54:01 +02:00
Kosta
25f4892aa1 removed unused argument names 2014-09-04 15:56:21 +02:00
Kosta
8b2faff981 enhance IterativeParsingReaderHandler to check for Key() events 2014-09-04 15:51:09 +02:00
Kosta
c8da4d86fc add Key()->String() forwarding to the capitalize example 2014-09-04 15:35:01 +02:00
Kosta
0f4071046f fix simplereader.cpp and the Key()->String() forwarding in BaseReaderHandler 2014-09-04 15:30:44 +02:00
Kosta
23b3d24355 add Key() to IterativeParsingReaderHandler in readertest.cpp` 2014-09-04 15:24:52 +02:00
Kosta
17b1a14d62 add Key() method to Writer and PrettyWriter 2014-09-04 15:20:05 +02:00
Kosta
57e1c87553 add Key() method to the Handler concept
For more details see: https://github.com/miloyip/rapidjson/issues/132

This commit tries to minimize the required code changes and forwards the `Handler::Key()` calls to `Handler::String()` wherever possible in order to not break existing code; or at least not code deriving from `BaseReaderHandler` when implementing a custom `Handler`.
2014-09-04 15:14:18 +02:00
Milo Yip
bc9d7866be Merge pull request #128 from pah/feature/cxx11-move
Initial C++11 move support
2014-09-03 09:37:35 +08:00
Milo Yip
15d70d6a7b Merge pull request #127 from pah/feature/value-different-allocators
GenericValue: accept values with different allocators for read-only access
2014-09-03 09:37:15 +08:00
Milo Yip
c6e6bca22f Merge pull request #130 from pah/fixes/capacity-growth
GenericValue: reduce growth factor for array/object reallocations
2014-09-02 22:11:34 +08:00
Milo Yip
9289f3270d Merge pull request #131 from Kosta-Github/Kosta/short_string_optimization
short string optimization
2014-09-02 21:52:10 +08:00
Kosta
08e81097eb final fix for the unit test case... 2014-09-01 12:54:50 +02:00
Kosta
ba05ea52cf use rapidjson::Value::SizeType as the type for storing and comparing the string length 2014-09-01 12:52:36 +02:00
Kosta
609997565c unit test simplification for short string optimization 2014-09-01 12:46:04 +02:00
Kosta
88debcf02e typo fixed for the unit test implementation 2014-09-01 12:40:28 +02:00
Kosta
056d0dafe4 add unit test for testing edge cases of the short string optimization 2014-09-01 12:34:43 +02:00
Kosta
697cf407c2 fixed a compiler error not caught by VS2012... 2014-09-01 12:01:25 +02:00
Kosta
d2a374b40c allow the short string optimization to store one more character
The `ShortString` can represent zero-terminated strings up to `MaxSize` chars (excluding the terminating zero) and store a value to determine the length of the contained string in the last character `str[LenPos]` by storing `MaxSize - length` there. If the string to store has the maximal length of `MaxSize` (excluding the terminating zero) then `str[LenPos]` will store `0` and therefore act as the string terminator as well. For getting the string length back from that value just use `MaxSize - str[LenPos]`.

This allows to store `11`-chars strings in 32-bit mode and `15`-chars strings in 64-bit mode inline (for `UTF8`-encoded strings).
2014-09-01 11:52:09 +02:00
Philipp A. Hartmann
0d2761a59c GenericValue: round up during capacity growth
Suggested-by: @miloyip
2014-09-01 11:31:25 +02:00
Kosta
b92d0ebd1b code cleanup for StringEqual()
Instead of replicating the functionality of `GetString()` and `GetStringLength()` in `StringEqual()` it now calls these methods instead.
2014-09-01 11:15:52 +02:00
Kosta
3caa86c923 short string optimization
Since the payload (the `Data` union) of the current implementation of `GenericValue` is `12 bytes` (32 bit) or `16 bytes` (64 bit) it could store `UTF8`-encoded strings up to `10` or `14` chars plus the `terminating zero` character plus the string length:
``` C++
    struct ShortString {
        enum { MaxSize = sizeof(GenericValue::String) / sizeof(Ch) - sizeof(unsigned char) };
        Ch str[MaxSize];
        unsigned char length;
    };  // at most as many bytes as "String" above => 12 bytes in 32-bit mode, 16 bytes in 64-bit mode

```

This is achieved by introducing additional `kInlineStrFlag` and `kShortStringFlag` flags. When setting a new string value in `SetStringRaw(s, alloc)` it is first checked if the string is short enough to fit into the `inline string buffer` and if so the given source string will be copied into the new `ShortString` target instead of allocating additional memory for it.
2014-09-01 11:11:26 +02:00
Philipp A. Hartmann
f4f432801a GenericValue: reduce growth factor for array/object reallocations
As mentioned by @kosta-github in http://git.io/0gkYSg, the currently
used growth factor of 2 is suboptimal for memory performance.  An
extensive discussion can be found at [1].

This patch reduces the array/object capacity growth factor to 1.5, as
many C++ implementations have chosen to use.  In order to avoid
floating-point arithmetics for computing the new capacity, I did not
add any customization parameter for the factor and used a shift+add
instead.

[1] https://github.com/facebook/folly/blob/master/folly/docs/FBVector.md
2014-09-01 08:57:21 +02:00
Milo Yip
2a4e055590 Merge pull request #129 from pah/bug/compare-uint64-double
Failing comparisons between certain (Ui|I)nt64 numbers
2014-09-01 12:09:31 +08:00
Philipp A. Hartmann
8ae2266c3b GenericStringRef: add NOEXCEPT, add ASSERT
* constructor from array is RAPIDJSON_NOEXCEPT
 * constructor from plain pointer missed an assert
2014-08-31 22:01:57 +02:00
Philipp A. Hartmann
56625bd9f0 GenericValue: add some more RAPIDJSON_NOEXCEPT
* Move()
 * RawAssign()
 * SetStringRaw()
2014-08-31 22:00:39 +02:00
Philipp A. Hartmann
fd2ba0bc44 GenericValue: fix comparison of (Ui|I)nt64 numbers
Some 64-bit integers cannot be represented losslessly as a double.
Due to a typo in the operator==, the comparison has been performed
after a double conversion in too many cases.
2014-08-31 19:01:16 +02:00
Philipp A. Hartmann
47c32eee6b valuetest: add test for Uint64 comparisons 2014-08-31 19:01:16 +02:00