summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2016-01-24Fix whitespace issuesStephan Beyer
Git warns when it finds "whitespace errors". This commit gets rid of these whitespace errors for code and adoc files.
2016-01-20Change header format in non-compact mode to store page offsetArseny Kapoulkine
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.
2016-01-12Preserve order semantics for child_value/text when using parse_embed_pcdataArseny Kapoulkine
The performance cost is probably negligible and this means we treat embedded value as the first child consistently.
2016-01-12Adjust parse_embed_pcdata documentationArseny Kapoulkine
Since round-tripping should not be a problem any more don't mention it.
2016-01-12Only save first PCDATA contents in the elementArseny Kapoulkine
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.
2016-01-09Implement output support for embedded PCDATA valuesArseny Kapoulkine
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.
2016-01-08Support XPath string value for parse_embed_pcdataArseny Kapoulkine
2016-01-08Support xml_node::child_value/text for parse_embed_pcdataArseny Kapoulkine
2016-01-08Add initial support for parse_embed_pcdataArseny Kapoulkine
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.
2015-12-31Update all license/copyright texts to 2016Arseny Kapoulkine
2015-12-29Work around Clang Wstring-conversion warningsArseny Kapoulkine
(!"string") triggers the warning however (false && "string") does not. Fixes #75.
2015-11-13Work around MinGW versions with non-C99 compliant headersArseny Kapoulkine
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.
2015-10-25Fix Borland C++ 5.4 compilationArseny Kapoulkine
It does not have stdint.h and has some C++ parsing issues.
2015-10-18Fix wchar modeArseny Kapoulkine
2015-10-18Fix MWCW issue with compact modeArseny Kapoulkine
2015-10-18Fix Borland C++ issues with compact modeArseny Kapoulkine
2015-10-18Work around DMC compilation errorArseny Kapoulkine
For some reason reference to a fixed-size array works in two other places but not in this one...
2015-10-18Fix 'cast increases required alignment of type' warningsArseny Kapoulkine
These show up when building with Wcast-align for ARM.
2015-10-17Fix XPath query move ctor/operatorArseny Kapoulkine
It now also moves parse result.
2015-10-17Fix 'signed/unsigned comparison' warning in wchar modeArseny Kapoulkine
Only happens on GCC 3.4 for some reason.
2015-10-17Fix -Wshadow warningArseny Kapoulkine
2015-10-17Fix MSVC6 header-only buildArseny Kapoulkine
name_sentry dtor results in multiple symbol definition errors in MSVC6.
2015-10-17Fix integer overflow detection with leading zerosArseny Kapoulkine
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.
2015-10-17Use explicit tests in set_Name/set_valueArseny Kapoulkine
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.
2015-10-17Fix argument mismatch in integer parsingArseny Kapoulkine
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.
2015-10-17Add compact_hash_table assertionsArseny Kapoulkine
2015-10-12Refactor output buffer encodingArseny Kapoulkine
Share the implementation for different encodings. We still need two functions because endian_swap on uint8_t is ambiguous...
2015-10-10Update version to 1.7Arseny Kapoulkine
2015-10-09Refactor utf_decoder classesArseny Kapoulkine
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.
2015-10-07Use correct type for lead in decode_utf16_blockArseny Kapoulkine
This does not affect correctness but makes code more uniform.
2015-10-07Refactor decode_utfN_block and decode_latin1_blockArseny Kapoulkine
Make sure the looping structure is the same as in decode_utf8_block.
2015-10-07Simplify file/stream loading flowArseny Kapoulkine
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.
2015-10-06Fixed missing PUGI__FNA. Breust
2015-09-21Fix parsing of integers that start with +Arseny Kapoulkine
This matches the format strtol supports.
2015-09-20Fix signed/unsigned warnings for MSVCArseny Kapoulkine
2015-09-20Implement custom string to integer conversionArseny Kapoulkine
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.
2015-09-20Remove extra const from operator= declarationArseny Kapoulkine
This does not really matter too much but it's better to be consistent.
2015-09-20Inline widen_ascii to get rid of an extra strlen callArseny Kapoulkine
Also since this function is only used once and is not defined in regular mode to avoid warnings this simplifies code a bit.
2015-09-20Eliminate redundant strlen calls during set_value/setArseny Kapoulkine
Since we use manual integer conversion we know the length of the string. This makes set_value(int) ~30% faster for 4-digit numbers.
2015-09-20Force callers of strcpy_insitu to compute string lengthArseny Kapoulkine
This makes it possible to avoid calling strlen if we already know the string size.
2015-09-20Implement integer to string conversion manuallyArseny Kapoulkine
This reduces the amount of non-standard C++ functionality pugixml may be using by avoiding sprintf with %lld; additionally this implementation is significantly faster (4-5x) than sprintf, mostly due to avoiding format string parsing and stream setup that commonly happens in CRT implementations. This comes at the expense of requiring long long division/remainder operations if PUGIXML_USE_LONG_LONG is defined which will surely bite me one day.
2015-08-14docs: Add PUGIXML_COMPACT documentationArseny Kapoulkine
Also add PUGIXML_COMPACT to pugiconfig.hpp
2015-08-14Minor get_integer_base optimizationArseny Kapoulkine
Remove an extra branch.
2015-07-26Fix two UB sanitizer false positivesArseny Kapoulkine
Change the expression to reference the array element indirectly. The memory block can be bigger than the structure so it's invalid to use static data[] size for bounds checking.
2015-07-25XPath: Increase memory block alignment to 8 bytesArseny Kapoulkine
To be more precise, the memory block is now aligned to be able to reliably allocate objects with both double and pointer fields. If there is a platform with a 4-byte double and a 4-byte pointer, the memory block alignment there will stay the same after this change. Fixes #48.
2015-07-25XPath: Refactor block allocationArseny Kapoulkine
Extract memory page size and block alignment into named constants.
2015-07-22XPath: Split optimize into optimize and optimize_selfArseny Kapoulkine
This makes the code slightly more readable, but more importantly it fixes a false positive in Clang static analyzer. Fixes #47.
2015-06-12Fix Clang 3.7 compatibilityArseny Kapoulkine
Apparently Clang 3.7 implements C++ DR 1748 that makes placement new with null pointer undefined behavior. Which renders all C++ programs that rely on this invalid. Which includes pugixml. This is not very likely to happen in the wild because the allocations that are subject to this in pugixml are relatively small, but tests break because of this. Fix the issue by adding null pointer checks (that are completely redundant in all current compilers except Clang 3.7 but it's not like there is another option).
2015-05-22Fix MSVC7 compilationArseny Kapoulkine
Work around a name lookup bug by pulling auto_deleter name in the local scope. We could also move auto_deleter to pugi:: namespace, but that pollutes it unnecessarily for other compilers.
2015-05-22Move default value handling into as_ functionsArseny Kapoulkine
This makes get_value_* simpler and also works around DMC compilation issue.