summaryrefslogtreecommitdiff
path: root/src/pugixml.cpp
AgeCommit message (Collapse)Author
2014-09-22Optimize and refactor node output implementation a bit (+5% perf gain)Arseny Kapoulkine
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1019 99668b35-9821-0410-8761-19e4c4f06640
2014-09-21Optimize text_output_indentArseny Kapoulkine
We now precompute indent length and have a fast path for lengths 0..4 that avoids calling memcpy in a tight loop. This makes node output 20-30% faster if indentation is enabled. git-svn-id: https://pugixml.googlecode.com/svn/trunk@1018 99668b35-9821-0410-8761-19e4c4f06640
2014-09-21Implement non-recursive node outputArseny Kapoulkine
This makes node output 3% faster, prevents it from ever running out of stack space and makes the profiling results more actionable for profilers that can't merge information from recursive calls. git-svn-id: https://pugixml.googlecode.com/svn/trunk@1014 99668b35-9821-0410-8761-19e4c4f06640
2014-09-15Fix VC 14 warningsArseny Kapoulkine
Fixes C4458: declaration of 'var' hides class member git-svn-id: https://pugixml.googlecode.com/svn/trunk@1011 99668b35-9821-0410-8761-19e4c4f06640
2014-08-26Unroll performance-critical loops 4xArseny Kapoulkine
Use a special macro that unrolls the loop body and uses static branch prediction to improve code generation. This increases performance across all data sets from benchmark; clang x64 is 10%-40% faster, clang x86 is 5%-20% faster, msvc is 5%-10% faster. git-svn-id: https://pugixml.googlecode.com/svn/trunk@1008 99668b35-9821-0410-8761-19e4c4f06640
2014-08-25Use PUGI__SCANWHILE for strconv utilitiesArseny Kapoulkine
This makes it easier to optimize strconv. For consistency move all definitions of parser-internal macros to one place. git-svn-id: https://pugixml.googlecode.com/svn/trunk@1007 99668b35-9821-0410-8761-19e4c4f06640
2014-08-25Rename ENDSWITH to PUGI__ENDSWITHArseny Kapoulkine
Also add it to #undef list at the end to avoid conflicts git-svn-id: https://pugixml.googlecode.com/svn/trunk@1006 99668b35-9821-0410-8761-19e4c4f06640
2014-08-11Move attribute name setup after pointer setup to handle exceptions betterArseny Kapoulkine
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1005 99668b35-9821-0410-8761-19e4c4f06640
2014-08-10Implement node moving functions.Arseny Kapoulkine
The operations itself are O(1) since they just rearrange pointers. However, the validation step is O(logN) due to a sanity check to prevent recursive trees. git-svn-id: https://pugixml.googlecode.com/svn/trunk@1002 99668b35-9821-0410-8761-19e4c4f06640
2014-08-10Refactor low-level node manipulation routines into separate functions.Arseny Kapoulkine
This should make moving implementation easier. git-svn-id: https://pugixml.googlecode.com/svn/trunk@1001 99668b35-9821-0410-8761-19e4c4f06640
2014-06-01Improve XPath allocator performanceArseny Kapoulkine
When allocating new pages, make sure that the page has at least 1/4 of the base page size free. This makes sure that we can do small allocations after big allocations (i.e. huge node lists) without doing a heap alloc. This is important because XPath stack code always reclaims extra pages after evaluating sub-expressions, so allocating a small chunk of memory and then rolling the state back is a common case (filtering a node list using a predicate usually does this). A better solution involves smarter allocation rollback strategy, but the implemented solution is simple and practical. git-svn-id: https://pugixml.googlecode.com/svn/trunk@999 99668b35-9821-0410-8761-19e4c4f06640
2014-02-25Add parse_trim_pcdata parse option.Arseny Kapoulkine
git-svn-id: https://pugixml.googlecode.com/svn/trunk@987 99668b35-9821-0410-8761-19e4c4f06640
2014-02-23Fix gap collapsing during PCDATA parsing for fragment mode.Arseny Kapoulkine
git-svn-id: https://pugixml.googlecode.com/svn/trunk@985 99668b35-9821-0410-8761-19e4c4f06640
2014-02-12Fix compilation warning for toolsets where wchar_t == char.Arseny Kapoulkine
git-svn-id: https://pugixml.googlecode.com/svn/trunk@983 99668b35-9821-0410-8761-19e4c4f06640
2014-02-11Implement document fragment parsing.Arseny Kapoulkine
Introduce a notable behavior change in default parsing mode: documents without a document element node are now considered invalid. This is technically a breaking change, however the amount of documents it affects is very small, all parsed data still persists, and lack of this check results in very confusing behavior in a number of cases. In order to be able to parse documents without an element node, a fragment parsing flag is introduced. Parsing a buffer in fragment mode treats the buffer as a fragment of a valid XML. As a consequence, top-level PCDATA is added to the tree; additionally, there are no restrictions on the number of nodes -- so documents without a document element are considered valid. Due to the way parsing works internally, load_buffer_inplace occasionally can not preserve the document contents if it's parsed in a fragment mode. While unfortunate, this problem is fundamental; since the use case is relatively obscure, hopefully documenting this shortcoming will be enough. git-svn-id: https://pugixml.googlecode.com/svn/trunk@980 99668b35-9821-0410-8761-19e4c4f06640
2014-02-10Use a null-terminated buffer for parsing as often as possible.Arseny Kapoulkine
Parsing used to work on a non null-terminated buffer, inserting a fake null terminator to increase performance. This makes it impossible to implement fragment parsing that preserves PCDATA contents (as witnessed by some tests for boundary conditions that actually depended on this behavior). Since almost all uses result in us allocating an internal buffer anyway, the new policy is to make sure all buffers that are allocated by pugixml are null-terminated - the only exception now is external calls to load_buffer_inplace that don't trigger encoding conversion. git-svn-id: https://pugixml.googlecode.com/svn/trunk@977 99668b35-9821-0410-8761-19e4c4f06640
2014-02-10Rename parse to parse_tree and convert_buffer to convert_buffer_output to ↵Arseny Kapoulkine
reduce overloading. git-svn-id: https://pugixml.googlecode.com/svn/trunk@975 99668b35-9821-0410-8761-19e4c4f06640
2014-02-08Update version to 1.4 and copyright year to 2014.Arseny Kapoulkine
Add tentative changelog for 1.4 to the documentation. Since Google Code no longer allows file upload, replace download links with GitHub release links. git-svn-id: http://pugixml.googlecode.com/svn/trunk@968 99668b35-9821-0410-8761-19e4c4f06640
2014-02-08Enable long long support for C++11 and for MSVC 2008+Arseny Kapoulkine
git-svn-id: http://pugixml.googlecode.com/svn/trunk@967 99668b35-9821-0410-8761-19e4c4f06640
2014-02-08Implement long long support if PUGIXML_HAS_LONG_LONG is defined ↵Arseny Kapoulkine
(autodetection is not implemented yet) git-svn-id: http://pugixml.googlecode.com/svn/trunk@962 99668b35-9821-0410-8761-19e4c4f06640
2014-01-27Ignore stream errors generated by a failing tellg() for non-seekable streamsArseny Kapoulkine
git-svn-id: http://pugixml.googlecode.com/svn/trunk@961 99668b35-9821-0410-8761-19e4c4f06640
2014-01-27Change xml_named_node_iterator to be bidirectional and to match ↵Arseny Kapoulkine
xml_node_iterator in terms of internals git-svn-id: http://pugixml.googlecode.com/svn/trunk@960 99668b35-9821-0410-8761-19e4c4f06640
2014-01-15Replace offsetof with sizeof since some compilers don't recognize offsetof ↵Arseny Kapoulkine
as a compile-time constant expression git-svn-id: http://pugixml.googlecode.com/svn/trunk@959 99668b35-9821-0410-8761-19e4c4f06640
2014-01-15Implement automatic hexadecimal decoding for xml_attribute::as_int and ↵Arseny Kapoulkine
xml_text::as_int. This is effectively a form of strtol with base 0, but without octal support. git-svn-id: http://pugixml.googlecode.com/svn/trunk@958 99668b35-9821-0410-8761-19e4c4f06640
2013-12-20Fix gcc-4.9 compilation warning when using -Wstrict-overflowarseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@957 99668b35-9821-0410-8761-19e4c4f06640
2013-11-26Fix gcc-4.8 compilation warning when using -Wstrict-overflowarseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@956 99668b35-9821-0410-8761-19e4c4f06640
2013-08-02Fix _root checking inconsistency in xml_document::destroyarseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@955 99668b35-9821-0410-8761-19e4c4f06640
2013-03-20Fix invalid assertion in XPath: reallocation can result in allocating buffer ↵arseny.kapoulkine@gmail.com
of the same size due to pointer-sized alignment git-svn-id: http://pugixml.googlecode.com/svn/trunk@946 99668b35-9821-0410-8761-19e4c4f06640
2013-03-19Fix XPath return type for contains() and string-length()arseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@944 99668b35-9821-0410-8761-19e4c4f06640
2012-12-08Work around clang static analysis false positives using extra assertions.arseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@943 99668b35-9821-0410-8761-19e4c4f06640
2012-12-07Only include wchar.h in PUGIXML_WCHAR_MODE; use a custom implementation of ↵arseny.kapoulkine@gmail.com
wcslen in case there is no wide character support. git-svn-id: http://pugixml.googlecode.com/svn/trunk@942 99668b35-9821-0410-8761-19e4c4f06640
2012-12-07Fix uninitialized variable in case append_buffer fails with out of memory ↵arseny.kapoulkine@gmail.com
due to buffer copy allocation git-svn-id: http://pugixml.googlecode.com/svn/trunk@941 99668b35-9821-0410-8761-19e4c4f06640
2012-12-07Compatibility fixes (fixed warnings in gcc, msvc7, fixed errors in bcc, cw, ↵arseny.kapoulkine@gmail.com
msvc6) git-svn-id: http://pugixml.googlecode.com/svn/trunk@939 99668b35-9821-0410-8761-19e4c4f06640
2012-12-07Implement xml_node::append_buffer as a faster alternative to assembling ↵arseny.kapoulkine@gmail.com
documents from fragments (compared to parse & clone) git-svn-id: http://pugixml.googlecode.com/svn/trunk@936 99668b35-9821-0410-8761-19e4c4f06640
2012-11-18XPath stack optimization: Reduce convert_number_to_string stack usage by ↵arseny.kapoulkine@gmail.com
reducing mantissa_buffer size and filling resulting string on heap without an extra copy from stack. git-svn-id: http://pugixml.googlecode.com/svn/trunk@933 99668b35-9821-0410-8761-19e4c4f06640
2012-11-18XPath: Fix BCC/DMC compilation (overloading workaround)arseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@932 99668b35-9821-0410-8761-19e4c4f06640
2012-11-18XPath stack optimization: Rewrite part of the recursive descent parser to ↵arseny.kapoulkine@gmail.com
precedence climbing to reduce stack usage git-svn-id: http://pugixml.googlecode.com/svn/trunk@931 99668b35-9821-0410-8761-19e4c4f06640
2012-11-17XPath stack optimization: Reduce stack usage during parsing by sharing ↵arseny.kapoulkine@gmail.com
scratch buffer for variable/number parsing (we only need one per parser) git-svn-id: http://pugixml.googlecode.com/svn/trunk@928 99668b35-9821-0410-8761-19e4c4f06640
2012-11-08Fix undefined pointer arithmetic for reverse() and unique() in case the ↵arseny.kapoulkine@gmail.com
range is empty (begin == end) git-svn-id: http://pugixml.googlecode.com/svn/trunk@926 99668b35-9821-0410-8761-19e4c4f06640
2012-10-31Minor refactoringarseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@923 99668b35-9821-0410-8761-19e4c4f06640
2012-10-31Adjust parsing so that it is possible to parse a document fragment into an ↵arseny.kapoulkine@gmail.com
existing subtree; can be used to implement append_buffer. git-svn-id: http://pugixml.googlecode.com/svn/trunk@922 99668b35-9821-0410-8761-19e4c4f06640
2012-09-29Fix find_child_by_attribute assertion for attributes with null name/value.arseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@920 99668b35-9821-0410-8761-19e4c4f06640
2012-05-02Iterator improvements: safety assertions in xml_named_node_iterator, ↵v1.2arseny.kapoulkine@gmail.com
const_cast workaround for BCC32 bug git-svn-id: http://pugixml.googlecode.com/svn/trunk@915 99668b35-9821-0410-8761-19e4c4f06640
2012-04-12Removed diag_push for SNC since the warning bug is not fixed even in the ↵arseny.kapoulkine@gmail.com
latest version git-svn-id: http://pugixml.googlecode.com/svn/trunk@901 99668b35-9821-0410-8761-19e4c4f06640
2012-04-03Updated version number and copyright year everywherearseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@897 99668b35-9821-0410-8761-19e4c4f06640
2012-04-03Whitespace-only change: set noexpandtab & retab!arseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@896 99668b35-9821-0410-8761-19e4c4f06640
2012-04-03Fixed xml_named_node_iterator category for MSVC6/7, IC8 and SunCCarseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@895 99668b35-9821-0410-8761-19e4c4f06640
2012-04-03Added xml_attribute::as_string and xml_text::as_string, added default value ↵arseny.kapoulkine@gmail.com
to all as_* member functions git-svn-id: http://pugixml.googlecode.com/svn/trunk@893 99668b35-9821-0410-8761-19e4c4f06640
2012-03-27Introduced xml_named_node_iterator, introduced xml_node::children() and ↵arseny.kapoulkine@gmail.com
xml_node::attributes() for C++11 range-based for loop git-svn-id: http://pugixml.googlecode.com/svn/trunk@889 99668b35-9821-0410-8761-19e4c4f06640
2012-03-27Write BOM as U+FEFF to buffered writer; this makes sure we don't have a very ↵arseny.kapoulkine@gmail.com
small unbuffered write with custom writer implementations git-svn-id: http://pugixml.googlecode.com/svn/trunk@887 99668b35-9821-0410-8761-19e4c4f06640