- Feb 27, 2019
-
-
Arseny Kapoulkine authored
Given an unsorted sequence, remove_duplicates would sort it using the pointer value of attributes/nodes and then remove consecutive duplicates. This was problematic because it meant that the result of XPath queries was dependent on the memory allocation pattern. While it's technically incorrect to rely on the order, this results in easy to miss bugs. This is particularly common when XPath queries use union operators - although we also will call remove_duplicates in other cases. This change reworks the code to use a hash set instead, using the same hash function we use for compact storage. To make sure it performs well, we allocate enough buckets for count * 1.5 (assuming all elements are unique); since each bucket is a single pointer unlike xpath_node which is two pointers, we need somewhere between size * 0.75 and size * 1.5 temporary storage. The resulting filtering is stable - we remove elements that we have seen before but we don't change the order - and is actually significantly faster than sorting was. With a large union operation, before this change it took ~56 ms per 100 query invocations to remove duplicates, and after this change it takes ~20ms. Fixes #254.
-
Arseny Kapoulkine authored
This does not change the result of a union operation [substantially], but it means that we now give a list to remove_duplicates that has more natural ordering. If remove_duplicates didn't sort the array, we'd have union operations resulting in a consistent predictable order. Contributes to #254.
-
- Jan 01, 2019
-
-
Arseny Kapoulkine authored
-
- Nov 24, 2018
-
-
Arseny Kapoulkine authored
We had a few places in test code and library source where we used an implicit float->double cast; while it should preserve the value exactly, gcc/clang implement this warning to make sure uses of double are intentional. This change also adds the warning to Makefile to make sure we don't regress on this warning. Fixes #243.
-
- Nov 20, 2018
-
-
Arseny Kapoulkine authored
This change modifies the table entries for ctx_special_attr to treat TAB character as special, which makes the output code escape it. Before this change, trying to use TAB in an attribute value would output it verbatim; during subsequent parsing, pugixml - and other compliant parsers - would apply attribute-value normalization, turning the TAB into a space and losing the original value. Using 	 fixes this; if an input document has 	 in an attribute value, that gets unescaped into \t during parsing and escaped back into 	 during output, which means we can now roundtrip values like this. Fixes #242.
-
- Nov 16, 2018
-
-
cecilios authored
-
- Nov 12, 2018
-
-
Arseny Kapoulkine authored
-
- Oct 24, 2018
-
-
Arseny Kapoulkine authored
Coverity hits a similar false positive to what clang static analyzer hit - it assumes that since optimize() checks _right for being nullptr, optimize_self() might hit _right=nullptr in the ast_op_equal case which is impossible. Contributes to #236.
-
- Oct 16, 2018
-
-
Lipsa, Dan authored
The following warning is removed: Visual Studio 14.0 1. warning C4275: non dll-interface class 'std::exception' used as base for dll-interface class 'vtkpugixml::xpath_exception'
-
- Sep 25, 2018
-
-
Arseny Kapoulkine authored
clang doesn't understand the invariants guaranteed for specific AST node types and, when seeing null pointer checks in optimize(), assumes any pointers in the node might be null. Work around this by adding explicit - redundant - null pointer checks.
-
Arseny Kapoulkine authored
This change replaces xpath_node_set single element storage with a single-element array in hopes that this would silence Coverity false positive about getting a singleton pointer. Additionally, it refactors _assign member to unify small and large buffer codepaths since they are basically identical. Fixes #233 (hopefully)
-
- Jul 28, 2018
-
-
Arseny Kapoulkine authored
Fixes #224.
-
- Apr 15, 2018
-
-
Arseny Kapoulkine authored
-
Arseny Kapoulkine authored
This might have helped a bit with confusion in #195.
-
- Apr 03, 2018
-
-
Arseny Kapoulkine authored
-
Arseny Kapoulkine authored
gcc-8 produces "attribute directive ignored" warning for no_sanitize("unsigned-integer-overflow"); at some point gcc will introduce integer sanitizer support and we'll have to do this all over again but for now just don't emit the attribute.
-
- Mar 29, 2018
-
-
Arseny Kapoulkine authored
-
- Mar 17, 2018
-
-
Arseny Kapoulkine authored
We were using << compact_alignment_log2 instead of * compact_alignment for symmetry with the encoding where >> is crucial to keep code fast and round to negative infinity. For decoding, the results are the same and any reasonable compiler should convert *4 into <<2 so just use a multiplication - that doesn't trigger UB on negative numbers.
-
- Mar 16, 2018
-
-
Arseny Kapoulkine authored
We were using allocate_memory to allocate struct xml_extra_buffer that contains pointers; with compact mode, this allocation can be misaligned by 4b with 8b pointers; fix this by manually realigning the pointer.
-
Arseny Kapoulkine authored
We were misaligning document data on 64-bit platforms by placing 8b pointers at 4b offsets; fix this by reserving a full pointer worth of bytes for page marker.
-
Arseny Kapoulkine authored
Define noexcept using _MSC_VER instead of _MSC_FULL_VER (first release of MSVC 2015 should have it), remove redundant PUGIXML_HAS_NOEXCEPT and define PUGIXML_NOEXCEPT_IF_NOT_COMPACT in terms of PUGIXML_NOEXCEPT.
-
- Mar 03, 2018
-
-
Matthäus Brandl authored
* Adds noexcept specifiers to the move special members of xml_document, but only #ifndef PUGIXML_COMPACT
-
- Mar 02, 2018
-
-
Matthäus Brandl authored
* Adds a macro definition to be able to use noexcept with supporting compilers * Adds noexcept specifier to move special members of xpath_node_set, xpath_variable_set and xpath_query, but not of xml_document as it has a throwing implementation
-
- Feb 27, 2018
-
-
Brandl, Matthäus (MBR) authored
Enables usage of override specifier for MSVC compilers (beginning with 17.0 which is the compiler of Visual Studio 2012)
-
Arseny Kapoulkine authored
Texas Instruments compiler produces this warning for unused template member functions: "pugixml.cpp", line 253: warning #179-D: function "pugi::impl::<unnamed>::auto_deleter<T>::release [with T=pugi::impl::<unnamed>::xml_stream_chunk<char>]" was declared but never referenced As far as I can tell, this is a compiler issue - these functions should not be instantiated in the first place; while it's possible to rework the code to work around this, the changes would be fragile. It seems best to just disable this warning - we've seen something similar on SNC (which appears to use the same frontend!..). Fixes #182.
-
- Feb 22, 2018
-
-
Arseny Kapoulkine authored
It looks like there are several cases where this might happen: - In some MinGW distributions, the LLONG_MIN/etc defines are guarded with: #if !defined(__STRICT_ANSI__) && defined(__GNUC__) Which means that you don't get them in strict ANSI mode. The previous workaround was specifically targeted towards this. - In some GCC distributions (notably GCC 6.3.0 in some configurations), LLONG_MIN/etc. defines are guarded with: #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) But __STDC_VERSION__ isn't defined as C99 even if you use -std=c++14 - which is probably technically valid, but not useful. To work around this, redefine the symbols whenever we are building with GCC and we need them and they aren't defined - doing this is better than not building. Instead of hard-coding the constants, use GCC-specific __LONG_LONG_MAX__ to compute them. Fixes #181.
-
- Jan 08, 2018
-
-
Arseny Kapoulkine authored
-
- Nov 14, 2017
-
-
Arseny Kapoulkine authored
This makes it a bit faster and matches other internal code better.
-
Arseny Kapoulkine authored
The static_buffer optimization seems to come from the time where the on-heap buffer was allocated using global memory operations. At this point the temporary buffer and temporary string storage all come from the evaluation stack (that can be partially allocated on heap...), so the extra logic isn't relevant for performance.
-
- Nov 13, 2017
-
-
Arseny Kapoulkine authored
-
Arseny Kapoulkine authored
In compact mode, we currently can not support zero-allocation moves since some pointer assignments required during the move need to allocate hash table slots. This is mostly applicable to xml_document_struct::first_child, since the pointer to this element is used as a hash table key, but there are some contrived cases where parents of root's children need a hash slot and didn't have it before. These cases can be fixed by changing the compact encoding to be a bit more move friendly, but for now it's easier to handle the error and throw/return during move. When this happens, the source document doesn't change.
-
Arseny Kapoulkine authored
This allows us to do a single reserve for a known amount of assignments that is larger than the default minimum per reserve (16).
-
- Oct 21, 2017
-
-
Arseny Kapoulkine authored
After move some nodes in the hash table can have keys that point to other; this makes the table somewhat larger but this does not impact correctness. The reason is that for us to access a key in the hash table, there should be a compact_pointer/string object with the state indicating that it is stored in a hash table, and with the address matching the key. For this to happen, we had to have put this object into this state which would mean that we'd overwrite the hash entry with the new, correct value. When nodes/pages are being removed, we do not clean up keys from the hash table - it's safe for the same reason, and thus move doesn't introduce additional contracts here.
-
- Sep 26, 2017
-
-
Arseny Kapoulkine authored
-
Arseny Kapoulkine authored
This change implements the initial version of move construction and assignment support for documents. When moving a document to another document, we always make sure move target is in "clean" state (empty document), and proceed by relocating all structures in the most efficient way possible. Complications arise from the fact that the root (document) node is embedded into xml_document object, so all pointers to it have to change; this includes parent pointers of all first-level children as well as allocator pointers in all memory pages and previous pointer in the first on-heap memory page. Additionally, compact mode makes everything even more complicated because some of the pointers we need to update are stored in the hash table (in fact, document first_child pointer is very likely to be there; some parent pointers in first-level children will be using compact_shared_parent but some won't be) which requires allocating a new hash table which can fail. Some details of this process are not fully fleshed out, especially for compact mode; and this definitely requires many tests.
-
- Jul 18, 2017
-
-
Arseny Kapoulkine authored
Clang/C2 does not implement __builtin_expect; additionally we need to work around deprecation warnings for fopen by disabling them.
-
- Jun 23, 2017
-
-
Arseny Kapoulkine authored
It's not clear whether we still need PUGI__MSVC_CRT_VERSION, but it's more consistent for now to use it for _snprintf_s since this is relying on a CRT extension, not on a compiler feature.
-
- Jun 22, 2017
-
-
Arseny Kapoulkine authored
These functions were deprecated via comments in 1.5 but never got the deprecated attribute; now is the time! Using deprecated functions produces a warning; to silence it, this change moves the relevant tests to a separate translation unit that has deprecation disabled.
-
- Jun 19, 2017
-
-
Arseny Kapoulkine authored
The macro only works correctly when the input argument is an array with a statically known size - pointers or arrays decayed to pointers won't work silently. While this is unlikely to surface issues that aren't caught in tests/code review, use _countof for MSVC to prevent such code from compiling.
-
- Jun 16, 2017
-
-
Arseny Kapoulkine authored
Rename partition to partition3 to resolve conflicts with std::partition.
-