summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
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.
2015-05-20XPath: Use strtod instead of atofArseny Kapoulkine
This makes code more consistent between wchar/utf8 mode.
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-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-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-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...
2015-05-02Implement efficient compact_header storageArseny Kapoulkine
Header is now just 2 bytes, with optional additonal 4 bytes that are only allocated for every 85 nodes / 128 attributes.
2015-05-01Implement compact_string with shared storageArseny Kapoulkine
2015-05-01Rename compact_string to compact_string_fatArseny Kapoulkine
2015-05-01Revert to name/value storage inside nodeArseny Kapoulkine
This temporarily increases the node size to 16 bytes - we'll bring it back. It allows us to remove the horrible node_pi hack and to reduce the amount of changes against master. This comes at the price of not decreasing basline xml_node_struct size. The compact xml_node_struct is also increased by this change but a followup change will reduce *both* xml_attribute_struct and xml_node_struct (to 8/12 bytes).
2015-04-29Refactor offset_debugArseny Kapoulkine
Split a long line into multiple statements.
2015-04-22Change xml_node_struct field order to match compactArseny Kapoulkine
Also remove useless comments.
2015-04-22Fix node_pi memory leakArseny Kapoulkine
2015-04-22Make xml_node::value() structure consistent with set_*Arseny Kapoulkine
2015-04-22Remove compact_header::operator uintptr_tArseny Kapoulkine
We used this in two cases - to get the page pointer and to test flags. We now use PUGI__GETPAGE for getting the page pointer and operator& to test flags - this makes getting node type significantly faster since it does not require page pointer reconstruction.
2015-04-22Remove redundant has_value checkArseny Kapoulkine
2015-04-22Use has_name/has_value in set_name/set_valueArseny Kapoulkine
2015-04-22Optimize and refactor compact_pointer implementationsArseny Kapoulkine
Clarify the offset applied when encoding the pointer difference. Make decoding diff slightly more clear - no effect on performance. Adjust branch weighting in compact_string encoding - 0.5% faster. Use uint16_t in compact_pointer_parent - 2% faster.
2015-04-21Optimize xml_allocator::reserve()Arseny Kapoulkine
Make sure compact_hash_table::rehash() is not inlined - that way reserve() is inlined so the fast path has no extra function calls. Also use subtraction instead of multiplication when checking capacity.
2015-04-21Merge branch 'master' into compactArseny Kapoulkine
2015-04-21XPath: Implement move semantics supportArseny Kapoulkine
xpath_query, xpath_node_set and xpath_variable_set are now moveable. This is a nice performance optimization for variable/node sets, and enables storing xpath_query in containers without using pointers (it's only possible now since the query is not copyable).
2015-04-21Fix compilation warning in some configurationsArseny Kapoulkine
2015-04-15Implement copy ctor/assignment for xpath_variable_setArseny Kapoulkine
xpath_variable_set is essentially an associative container; it's about time it became copyable. Implementation is slightly tricky due to out of memory handling. Both copy ctor and assignment operator have strong exception guarantee (even if exceptions are disabled! which translates to "roll back on allocation errors").
2015-04-15Minor xpath_variable refactoringArseny Kapoulkine
The type of the variable is now initialized correctly in the ctor, so that there is no interim invalid state.
2015-04-14Fix xpath_node_set assignment to provide strong exception guaranteeArseny Kapoulkine
Since the type of the set was updated before assignment, assigning in out-of-memory condition could change the type to not match the content.
2015-04-14Explicitly call xml_buffered_writer::flush()Arseny Kapoulkine
If xml_writer::write throws an exception while being called from flush(), the exception is thrown from destructor. Clang in C++11 mode calls std::terminate in this case.
2015-04-13Refactor format_indent_attributes implementationArseny Kapoulkine
Fix code style and revert redundant parameters/whitespace changes. Also remove format_each_attribute_on_new_line - we're only introducing one extra formatting flag. The flag implies format_indent but does not include its bitmask. Also add a few more tests. Fixes #14.
2015-04-14add align each attribute on new line support with format_indent_attributehalex2005
2015-04-12Merge branch 'master' into compactArseny Kapoulkine
2015-04-12Fix unused variable warningArseny Kapoulkine
Also fix test in wchar_t mode.
2015-04-12Permit custom allocation function to throwArseny Kapoulkine
Ensure that all the necessary cleanup is performed in case the allocation fails with an exception - files are closed, buffers are reclaimed, etc. Any test that triggers a simulated out-of-memory condition is ran once again with a throwing allocation function. Unobserved std::bad_alloc count as test failures and require CHECK_ALLOC_FAIL macro. Fixes #17.
2015-04-12Fix compilation and tests after merge.Arseny Kapoulkine
2015-04-12Merge branch 'master' into compactArseny Kapoulkine
2015-04-12Implment copyless copy for attributesArseny Kapoulkine
Previously attributes that were copied with their node used string sharing, but standalone attributes that were copied using xml_node::*_copy(xml_attribute) were not.