Age | Commit message (Collapse) | Author |
|
|
|
|
|
While I grew to dislike references for this case, there are other functions in
the source that use references so switch to that for consistency.
|
|
This adds about 40 cycles for parsing <?xml version='1.0'?> declaration and
about 70 cycles for parsing <?xml version='1.0' encoding='utf-8'?>, as
measured on a Core i7, which should be negligible for all documents.
Fixes #16.
|
|
Previously the page size was defining the data size, and due to additional
headers (+ recently removed allocation padding) the actual allocation was a bit
bigger.
The problem is that some allocators round 2^N+k allocations to 2^N+M, which can
result in noticeable waste of space. Specifically, on 64-bit OSX allocating the
previous page size (32k+40) resulted in 32k+512 allocation, thereby wasting 472
bytes, or 1.4%.
Now we have the allocation size specified exactly and just recompute the available
data size, which can in small space savings depending on the allocator.
|
|
When using format_raw the space in the empty tag (<node />) is the only
character that does not have to be there; so format_raw almost results in
a minimal XML but not quite.
It's pretty unlikely that this is crucial for any users - the formatting
change should be benign, and it's better to improve format_raw than to add
yet another flag.
Fixes #87.
|
|
Also rename auto_deleter_fclose to close_file.
|
|
compilers use a special calling convention for stdlib functions like fclose
|
|
Unify the implementations by automatically deducing the unsigned type from its
signed counterpart. That allows us to use a templated function instead of
duplicating code.
|
|
This makes the coverage for basic numeric types complete (sans long double).
Fixes #78.
|
|
Git warns when it finds "whitespace errors". This commit gets
rid of these whitespace errors for code and adoc files.
|
|
This utilizes the fact that pages are of limited size so we can store offset
from the object to the page in a few bits - we currently use 24 although that's
excessive given that pages are limited to ~512k.
This has several benefits:
- Pages do not have to be 64b aligned any more - this simplifies allocation flow
and frees up 40-50 bytes from xml_document::_memory.
- Header now has 8 bits available for metadata for both compact and default mode
which makes it possible to store type as-is (allowing easy type extension and
removing one add/sub operation from type checks).
- One extra bit is easily available for future metadata extension (in addition
to the bit for type encoding that could be reclaimed if necessary).
- Allocators that return 4b-aligned memory on 64-bit platforms work fine if
misaligned reads are supported.
The downside is that there is one or two extra instructions on the allocation
path. This does not seem to hurt parsing performance.
|
|
The performance cost is probably negligible and this means we treat embedded
value as the first child consistently.
|
|
Since round-tripping should not be a problem any more don't mention it.
|
|
This change fixes an important ordering issue - if element node has a PCDATA
child *after* other elements, it's impossible to tell which order the children
were in.
Since the goal of PCDATA embedding is to save memory when it's the only child,
only apply the optimization to the first child. This seems to fix all
roundtripping issues so the only caveat is that the DOM structure is different.
|
|
This is a bit awkward since preserving correct indentation structure requires
a bit of extra work, and the closing tag has to be written by _start function
to correctly process the rest of the tree.
|
|
|
|
|
|
When this flag is true, PCDATA value is saved to the parent element instead of
allocating a new node.
This prevents some documents from round-tripping since it loses information,
but can provide a significant memory reduction and parsing speedup for some
documents.
|
|
|
|
(!"string") triggers the warning however (false && "string") does not.
Fixes #75.
|
|
Apparently some MinGW distributions have a compiler that's recent enough to
support C++11 but limits.h header that incorrectly omits LLONG limits in
strict ANSI mode, since it guards the definitions with:
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
We can just define these symbols ourselves in this specific case.
Fixes #66.
|
|
It does not have stdint.h and has some C++ parsing issues.
|
|
|
|
|
|
|
|
For some reason reference to a fixed-size array works in two other places
but not in this one...
|
|
These show up when building with Wcast-align for ARM.
|
|
It now also moves parse result.
|
|
Only happens on GCC 3.4 for some reason.
|
|
|
|
name_sentry dtor results in multiple symbol definition errors in MSVC6.
|
|
Since they don't contribute to the resulting value just skip them before
parsing. This matches the behavior of strtol/strtoll and results in more
intuitive behavior.
|
|
Node type enum is not used as an array index anywhere else; the code is not
very readable and the value of this "optimization" is questionable.
The conditions are arranged so that in all normal cases the first comparison
returns true anyway.
|
|
The minneg argument is supposed to be the absolute value of the minimum negative
representable number. In case of two-complement arithmetic, it's the same as the
value itself but it's better to be explicit and negate the argument.
|
|
|
|
Share the implementation for different encodings. We still need two functions
because endian_swap on uint8_t is ambiguous...
|
|
|
|
Instead of functions with different names (e.g. decode_utf8_block), split
utf_decoder class into multiple classes with ::process static function.
This makes it easier to share code for decoding different encodings.
|
|
This does not affect correctness but makes code more uniform.
|
|
Make sure the looping structure is the same as in decode_utf8_block.
|
|
Instead of calling xml_document public functions just call implementation of
load_buffer_inplace_own. This makes it so we only call reset() once during
load_file/load.
|
|
|
|
This matches the format strtol supports.
|
|
|
|
This makes conversion significantly faster and removes more CRT dependencies;
in particular, to support long long pugixml only requires the type itself (and
the division operator...).
New implementation is up to 3x faster on short decimal numbers.
Note that unlike the old implementation, new implementation correctly handles
overflow and underflow and clamps the value to the representable range. This
means that there are some behavior changes - e.g. previously as_uint on "-1"
would return INT_MAX instead of 0.
In addition to CRT issues, for platforms with 64-bit long old implementation
incorrectly truncated from long to int or unsigned int, so even if CRT clamped
the values the result would have been incorrect.
|
|
This does not really matter too much but it's better to be consistent.
|
|
Also since this function is only used once and is not defined in regular mode
to avoid warnings this simplifies code a bit.
|
|
Since we use manual integer conversion we know the length of the string.
This makes set_value(int) ~30% faster for 4-digit numbers.
|
|
This makes it possible to avoid calling strlen if we already know the string
size.
|