summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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-09-19tests: Convert several files to Unix line endingsArseny Kapoulkine
They were still using Windows EOL by mistake
2015-08-25Update README.mdArseny Kapoulkine
2015-08-25build: Fix -o gcov optionArseny Kapoulkine
Also upload just pugixml.cpp.gcov to codecov to avoid issues the script has with old gcov.
2015-08-25build: Rework config=coverage to be more robustArseny Kapoulkine
Use find -exec instead of xargs to work around differences between xargs on OSX and Linux. Use -b option of gcov - for some reason gcov on Travis can't find .gcno files otherwise (old version?). And finally enable config=coverage again.
2015-08-25build: Disable config=coverage for nowArseny Kapoulkine
2015-08-25build: Actually use config=coverageArseny Kapoulkine
2015-08-25build: Test codecov.io integrationArseny Kapoulkine
2015-08-25build: Simplify coverage configurationArseny Kapoulkine
Use -coverage option and keep NDEBUG off
2015-08-14docs: Clarify UTF-8 vs wchar_t memory efficiencyArseny Kapoulkine
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-25tests: Fix test allocator to provide fundamental alignmentArseny Kapoulkine
Previously test allocator only guaranteed alignment enough for a pointer. On some platforms (e.g. SPARC) double has to be aligned to 8 bytes but pointers can have a size of 4 bytes. This commit increases allocation header to fix that. In practical terms the allocation header is now always 8 bytes.
2015-07-25XPath: Refactor block allocationArseny Kapoulkine
Extract memory page size and block alignment into named constants.
2015-07-25tests: Only enable page heap on x86/x64Arseny Kapoulkine
This fixes tests in PUGIXML_NO_XPATH mode on SPARC64 (#48). SPARC does not allow unaligned accesses - e.g. you can't read an unaligned int. Normally pugixml does not perform unaligned integer/pointer accesses, but page heap can allocate blocks that are not aligned so that we can detect a single- byte read/write overrun. Additionally, the hardcoded page size we're currently using is really system specific - on SPARC the page size can be 8 Kb instead of 4 Kb so mprotect can fail.
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-24docs: Clarify hash_value behaviorArseny Kapoulkine
Fixes #43.
2015-06-13Makefile now supports Xcode 7 ASANArseny Kapoulkine
All other sanitizers are still unavailable so only enable them on non-OSX systems.
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-22tests: Add newline at the end of fileArseny Kapoulkine
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-22tests: Fix MSVC6 compilationArseny Kapoulkine
2015-05-22Move default value handling into as_ functionsArseny Kapoulkine
This makes get_value_* simpler and also works around DMC compilation issue.
2015-05-20XPath: Use strtod instead of atofArseny Kapoulkine
This makes code more consistent between wchar/utf8 mode.
2015-05-20tests: Split fp roundtrip test into float and doubleArseny Kapoulkine
2015-05-14Implement xml_node::attribute with a hintArseny Kapoulkine
Extra argument 'hint' is used to start the attribute lookup; if the attribute is not found the lookup is restarted from the beginning of the attriubte list. This allows to optimize attribute lookups if you need to get many attributes from the node and can make assumptions about the likely ordering. The code is correct regardless of the order, but it is faster than using vanilla lookups if the order matches the calling order. Fixes #30.
2015-05-12tests: Fix address sanitizer detection for GCCArseny Kapoulkine
2015-05-12Add config=sanitize support to MakefileArseny Kapoulkine
2015-05-12Add Visual Studio 2015 to AppVeyorArseny Kapoulkine
2015-05-12tests: Disable page allocator if address sanitizer is activeArseny Kapoulkine
Address sanitizer can detect underflows so we don't really need the custom allocator. Additionally, custom allocator can return memory that is not pointer-aligned; this causes undefined behavior sanitizer to complain.
2015-05-12tests: Fix clang 3.7 warningArseny Kapoulkine
Work around -Wself-move using ref-deref.
2015-05-03Update README.mdArseny Kapoulkine
2015-05-03Update README.mdArseny Kapoulkine
2015-05-03Switch Travis CI to use DockerArseny Kapoulkine
2015-05-03Fix NO_STL+NO_XPATH modeArseny Kapoulkine
auto_deleter is now used in all modes so we can't exclude it from compilation.
2015-05-03tests: Fix MSVC6 compatibilityArseny Kapoulkine
Apply the usual workaround for for scoping issues. Also fix integer conversion warning for BorlandC.
2015-05-03Merge pull request #42 from zeux/compactArseny Kapoulkine
Implement compact mode. This introduces a new storage mode that dramatically reduces node size at some performance cost. The mode is enabled by defining PUGIXML_COMPACT. This does not change API/ABI - all existing functionality still works. The pointers are stored using delta encoding and bytes, with some additional tricks to make encoding more optimal for e.g. parent pointer and string pointers. Since the node is fixed size, we have to fall back to a hash table if the pointer does not fit. Thus all DOM operations still have amortized complexity - constant number of operations if you don't need the hash table and amortized constant if you do. Aside from some performance loss (which is inevitable since decoding takes time), the only other caveat is that we can't remove entries from the hash table - so in some edge cases with a lot of node removals the peak memory consumption can grow indefinitely. In theory we can implement this later; it's unclear that this is useful at this point. The resulting node/attribute sizes are as follows: non-compact node: 28b 32-bit, 56b 64-bit compact node: 12b 32/64-bit non-compact attribute: 20b 32-bit, 40b 64-bit compact attribute: 8b 32/64-bit
2015-05-03Cleanup before mergeArseny Kapoulkine
2015-05-03Fix MSVC warningArseny Kapoulkine
2015-05-02Fix MSVC buildArseny Kapoulkine
2015-05-02Reorder conditions in compact_string implementationArseny Kapoulkine
Now compact_string matches compact_pointer_parent. Turns out PUGI__UNLIKELY is good at reordering conditions but usually does not really affect performance. Since MSVC should treat "if" branches as taken and does not support branch probabilities, don't use them if we don't need to.
2015-05-02Minor refactoringArseny Kapoulkine
2015-05-02Revise marker deletion strategyArseny Kapoulkine
Instead of checking if the object being removed allocated a marker, mark the marker block as deleted immediately upon allocation. This simplifies the logic and prevents extra markers from being inserted if we allocate/deallocate the same node indefinitely. Also change marker pointer type to uint32_t*.
2015-05-02Optimize compact_stringArseny Kapoulkine
First assignment uses a fast path; second assignment uses a specialized path as well.
2015-05-02tests: Add one more page reclamation testArseny Kapoulkine
2015-05-02Fix node deallocationArseny Kapoulkine
When we deallocate nodes/attributes that allocated the marker we have to adjust the size accordingly, and dismiss the marker in case it gets overwritten with something else...