Commit Graph

1078 Commits

Author SHA1 Message Date
Arseny Kapoulkine
dede617d9f tests: Fix spurious failures in compact mode
The memory_large_allocations test sometimes classified hash allocations
as page allocations since hash table could reach 512 entries.
2015-04-29 09:21:04 -07:00
Arseny Kapoulkine
b2399f5ab5 Refactor offset_debug
Split a long line into multiple statements.
2015-04-29 09:20:08 -07:00
Arseny Kapoulkine
44e4f17348 Change xml_node_struct field order to match compact
Also remove useless comments.
2015-04-22 09:53:04 -07:00
Arseny Kapoulkine
3643b505a6 Fix node_pi memory leak 2015-04-22 08:38:52 -07:00
Arseny Kapoulkine
4223b4a3f0 Make xml_node::value() structure consistent with set_* 2015-04-22 08:30:53 -07:00
Arseny Kapoulkine
e4e2259646 Remove compact_header::operator uintptr_t
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-22 08:26:47 -07:00
Arseny Kapoulkine
12744fd1fa Remove redundant has_value check 2015-04-22 07:52:20 -07:00
Arseny Kapoulkine
b87160013b Use has_name/has_value in set_name/set_value 2015-04-22 07:51:02 -07:00
Arseny Kapoulkine
4649914447 Optimize and refactor compact_pointer implementations
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-22 07:36:32 -07:00
Arseny Kapoulkine
33b2efe318 Optimize xml_allocator::reserve()
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-21 23:02:44 -07:00
Arseny Kapoulkine
52bcb4ecd6 tests: Adjust allocation thresholds to fix tests 2015-04-21 21:35:54 -07:00
Arseny Kapoulkine
f9983ea2ed Merge branch 'master' into compact 2015-04-21 21:27:44 -07:00
Arseny Kapoulkine
a6cc636a6b tests: Fix MSVC warnings 2015-04-21 21:07:58 -07:00
Arseny Kapoulkine
250d020e9b Use -std=c++0x instead of -std=c++11 2015-04-21 20:46:33 -07:00
Arseny Kapoulkine
8d4544f2e1 Enable C++11 in Makefile 2015-04-21 20:32:40 -07:00
Arseny Kapoulkine
4eadece45f tests: Add move semantics tests
Also test ranged for and copying big xpath_variable_set objects (to make
sure we actually handle hash collisions properly)
2015-04-21 19:44:19 -07:00
Arseny Kapoulkine
83b894b8f1 XPath: Implement move semantics support
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-21 19:42:31 -07:00
Arseny Kapoulkine
a414c5c52d Fix compilation warning in some configurations 2015-04-21 10:02:26 -07:00
Arseny Kapoulkine
cbf3807ad4 Implement copy ctor/assignment for xpath_variable_set
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-15 23:22:31 -07:00
Arseny Kapoulkine
70a78b2fa5 tests: Fix Linux build 2015-04-15 22:11:13 -07:00
Arseny Kapoulkine
bb3aee447b tests: Use malloc for OSX/Linux page heap
Switch to malloc and manually aligning the pointer to the page boundary.

mmap is much slower than malloc; this change makes tests ~4x faster.
2015-04-15 21:44:52 -07:00
Arseny Kapoulkine
8c8940430a Minor xpath_variable refactoring
The type of the variable is now initialized correctly in the ctor, so that there
is no interim invalid state.
2015-04-15 08:34:14 -07:00
Arseny Kapoulkine
5158ee903b Fix xpath_node_set assignment to provide strong exception guarantee
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-14 19:23:36 -07:00
Arseny Kapoulkine
2badcbb674 Explicitly call xml_buffered_writer::flush()
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-14 19:11:26 -07:00
Arseny Kapoulkine
e977f04fe2 docs: Add format_indent_attributes documentation
Slightly reword format_indent description.
2015-04-13 21:50:24 -07:00
Arseny Kapoulkine
2a3435274f Refactor format_indent_attributes implementation
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-13 21:49:08 -07:00
Arseny Kapoulkine
950693be7f Merge branch 'AlignAttributesEachOnSeparateLine' of git://github.com/halex2005/pugixml into indent_attributes 2015-04-13 20:56:18 -07:00
Arseny Kapoulkine
f241318f9c Add branch name to AppVeyor version 2015-04-13 20:38:52 -07:00
Arseny Kapoulkine
cb786665d4 tests: Add PUGIXML_COMPACT to AppVeyor 2015-04-13 20:36:04 -07:00
Arseny Kapoulkine
ed2c822643 Merge branch 'master' into compact 2015-04-13 20:35:26 -07:00
Arseny Kapoulkine
1c4098a7d9 Remove all files for the Jamplus-based build system
End of an era.

Make can be used for regular development (Linux/OSX), documentation building
and release packaging.
CMake can be used for regular development (Windows); it's also used by some
Linux distributions.

Continuous integration is now performed by Travis CI and AppVeyor.
2015-04-13 20:30:14 -07:00
Arseny Kapoulkine
baacd81907 Fix AppVeyor script path 2015-04-13 20:10:45 -07:00
Arseny Kapoulkine
218ddd0376 Add AppVeyor build scripts 2015-04-13 20:03:49 -07:00
Arseny Kapoulkine
05032b4c06 scripts: Add an option for building tests with CMake 2015-04-13 20:02:09 -07:00
halex2005
5d66ae9fb9 add tests for aligning each attribute on next line 2015-04-14 00:56:42 +05:00
halex2005
6766f35338 add align each attribute on new line support with format_indent_attribute 2015-04-14 00:56:23 +05:00
Arseny Kapoulkine
054b0b447e Merge branch 'master' into compact 2015-04-12 22:09:45 -07:00
Arseny Kapoulkine
9539c488c2 Fix unused variable warning
Also fix test in wchar_t mode.
2015-04-12 22:06:17 -07:00
Arseny Kapoulkine
f04b56e178 Permit custom allocation function to throw
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-12 21:46:48 -07:00
Arseny Kapoulkine
5edeaf6765 tests: Add more out of memory tests
Also add tests that verify save_file for absence of FILE leaks.
2015-04-12 21:27:12 -07:00
Arseny Kapoulkine
6c11a0c693 Fix compilation and tests after merge. 2015-04-12 03:14:08 -07:00
Arseny Kapoulkine
a19da1c246 Merge branch 'master' into compact 2015-04-12 03:05:58 -07:00
Arseny Kapoulkine
a0d065cd22 Implment copyless copy for attributes
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.
2015-04-12 03:03:56 -07:00
Arseny Kapoulkine
c5d07e2c28 tests: Add a test that verifies absence of file leaks
If an out of memory error happens in load_file there's a danger of leaking
the FILE object. Since there is a limited supply of the objects we can easily
test that the leak does not happen.
2015-04-12 02:34:48 -07:00
Arseny Kapoulkine
2537cccad3 tests: Fix some Coverity issues 2015-04-12 02:17:20 -07:00
Arseny Kapoulkine
d6f7766172 Optimize xml_node::path() to use 1 allocation
Instead of reallocating the string for every tree level just do two passes
over the ancestor chain.
2015-04-12 02:12:15 -07:00
Arseny Kapoulkine
99afee1832 Move zero-termination out of as_utf8_end
as_utf8_end was used with std::string, where writing an extra zero-terminating
character should *probably* always work (at least if size is positive) but is
not ideal.

The only place that needed to zero-terminate was convert_path_heap.
2015-04-12 01:32:25 -07:00
Arseny Kapoulkine
3da7d68617 Fix Travis CI build. 2015-04-11 22:52:41 -07:00
Arseny Kapoulkine
4e004176ba tests: Improve out-of-memory tests
Previously there was no guarantee that the tests that check for out of memory
handling behavior are actually correct - e.g. that they correctly simulate out
of memory conditions.

Now every simulated out of memory condition has to be "guarded" using
CHECK_ALLOC_FAIL. It makes sure that every piece of code that is supposed to
cause out-of-memory does so, and that no other code runs out of memory
unnoticed.
2015-04-11 22:46:08 -07:00
Arseny Kapoulkine
37467c13bf tests: Add a test for throwing from xml_writer::write
We currently don't allocate/modify any state so there are no issues with this.
2015-04-11 22:44:42 -07:00