0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-31 00:13:01 +08:00

1068 Commits

Author SHA1 Message Date
Arseny Kapoulkine
50bfdb1856 tests: Fix all tests for compact mode
Memory allocation behavior is different in compact mode so tests that rely
on current behavior have to be adjusted.
2014-11-06 09:59:07 +01:00
Arseny Kapoulkine
393cc28481 Add compact build configuration to Travis 2014-11-06 09:34:13 +01:00
Arseny Kapoulkine
56349939e4 Verify that compact page encoding is safe
Since page size can be customized let's do a special validation check for
compact encoding. Right now it's redundant since page size is limited by
64k in alloc_string, but that may change in the future.
2014-11-06 09:33:05 +01:00
Arseny Kapoulkine
224b9b7ba7 Add a separate storage class for PI nodes
This allows us to add pi value to restore target support for PI nodes without
increasing the memory usage for other nodes.

Right now the PI node has a separate header that's used for allocated bit;
this allows us to reduce header bitcount in the future.
2014-11-06 09:20:34 +01:00
Arseny Kapoulkine
e3c215b542 Ensure selected page size works with allocate_string
Previously setting a large page size (i.e. 1M) would cause dynamic string
allocation to assert spuriously. A page size of 64K guarantees that all
offsets fit into 16 bits.
2014-11-05 09:52:12 +01:00
Arseny Kapoulkine
aa1a61c59f Fix xml_node::offset_debug for corner cases
Computed offsets for documents with nodes that were added using append_buffer
or newly appended nodes without name/value information were invalid.
2014-11-05 09:32:52 +01:00
Arseny Kapoulkine
ab12b30c83 Use impl::get_document instead of root() where possible
This reduces the number of unsafe pointer manipulations.
2014-11-05 09:19:12 +01:00
Arseny Kapoulkine
2cb5d40956 Remove redundant branches
These used to result in better codegen for unknown reasons, but this is no
longer the case.
2014-11-05 08:52:32 +01:00
Arseny Kapoulkine
f39a73f6e1 Fix gcc warnings in compact mode 2014-11-04 10:05:31 +01:00
Arseny Kapoulkine
b2a0ae13b6 Merge branch 'master' into compact 2014-11-04 09:58:04 +01:00
Matthias Loy
1912894f53 :Merge remote-tracking branch 'upstream/master' 2014-11-03 20:23:35 +01:00
Arseny Kapoulkine
3950ee0433 XPath: Refactor predicate application
Split number/boolean filtering logic into two functions. This creates an
extra copy of a remove_if-like algorithm, but moves the type check out of
the loop and results in better organized filtering code.

Consolidate test-based dispatch into apply_predicate (which is now a member
function).
2014-11-03 18:41:18 +01:00
Arseny Kapoulkine
97a515f873 tests: Add more XPath mod tests 2014-11-03 07:50:00 +01:00
Arseny Kapoulkine
e9948b4b05 Fix undefined behavior while calling memcpy
Calling memcpy(x, 0, 0) is technically undefined (although it should usually
be a no-op).
2014-11-02 09:30:56 +01:00
Arseny Kapoulkine
f68a320a02 tests: Improve test coverage 2014-11-01 11:45:13 +01:00
Arseny Kapoulkine
25926c6206 XPath: Fix undefined behavior while calling memcpy
Calling memcpy(x, 0, 0) is technically undefined (although it should usually
be a no-op).

Fixes #20.
2014-11-01 10:48:14 +01:00
Arseny Kapoulkine
97893ad738 Fix first-time make config=coverage test
Not sure why xargs -r is not the default...
2014-11-01 08:59:49 +01:00
mloy
837ced350c load_buffer_impl always checks if buffer is valid pointer and size > 0
added some tests to force invalid buffer and size = 0
2014-10-30 14:30:05 +01:00
Arseny Kapoulkine
650c67a663 Fix compilation after merge. 2014-10-28 20:14:17 -07:00
Arseny Kapoulkine
a49f932b61 Merge branch 'master' into compact 2014-10-28 20:11:06 -07:00
Arseny Kapoulkine
21cff3bca2 Fix several cppcheck warnings. 2014-10-28 17:10:41 -07:00
Arseny Kapoulkine
6229138d80 Optimize node printing by using raw pointers
This lets us do fewer null pointer checks (making printing 2% faster with -O3)
and removes a lot of function calls (making printing 20% faster with -O0).
2014-10-27 22:29:14 -07:00
Arseny Kapoulkine
c64d4820b1 XPath: Optimize [position()=expr] and [last()]
To get more benefits from constant predicate/filter optimization we rewrite
[position()=expr] predicates into [expr] for numeric expressions. Right now
the rewrite is only for entire expressions - it may be beneficial to split
complex expressions like [position()=constant and expr] into [constant][expr]
but that is more complicated.

last() does not depend on the node set contents so is "constant" as far as
our optimization is concerned so we can evaluate it once.
2014-10-27 18:50:09 -07:00
Arseny Kapoulkine
dbfe85a717 XPath: Only recognize numeric constant expressions
Numeric and boolean constant expressions in filters are different in that
to evaluate numeric expressions we need a sorted order, but to evaluate
boolean expressions we don't. The previously implemented optimization adds
an extra sorting step for constant boolean filters that will be more expensive
than redundant computations.

Since constant booleans are sort of an edge case, don't do this optimization.
This allows us to simplify apply_predicate_const to only handle numbers.
2014-10-26 10:27:50 -07:00
Arseny Kapoulkine
11ce004e04 XPath: Unify ast_filter/ast_predicate structure
Now expression is always _right for filter/predicate nodes to make optimize()
simpler. Additionally we now use predicate metadata to make is_posinv_step()
faster.

This introduces a weak ordering dependency in rewrite rules to optimize() -
classification has to be performed before other optimizations.
2014-10-26 10:11:22 -07:00
Arseny Kapoulkine
d5e29292c6 XPath: Optimize constant filters/predicates
If a filter/predicate expression is a constant, we don't need to evaluate it
for every nodeset element - we can evaluate it once and pick the right element
or keep/discard the entire collection.

If the expression is 1, we can early out on first node when evaluating the
node set - queries like following::item[1] are now significantly faster.

Additionally this change refactors filters/predicates to have additional
metadata describing the expression type in _test field that is filled during
optimization.

Note that predicate_constant selection right now is very simple (but captures
most common use cases except for maybe [last()]).
2014-10-26 09:37:18 -07:00
Arseny Kapoulkine
f31c14e1fd tests: Remove git2svn helper script! 2014-10-26 02:22:27 -07:00
Arseny Kapoulkine
3fc86dcdc6 Update README.md with new documentation URLs. 2014-10-26 02:21:29 -07:00
Arseny Kapoulkine
0e59ea8234 tests: Add a way for tests to verify allocation failure
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1081 99668b35-9821-0410-8761-19e4c4f06640
2014-10-26 03:46:28 +00:00
Arseny Kapoulkine
0b7964917c Fix node copying for some out of memory cases
A page can fail to allocate during attribute creation; this case was not
previously handled.

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1080 99668b35-9821-0410-8761-19e4c4f06640
2014-10-25 16:37:16 +00:00
Arseny Kapoulkine
503abf607a Add 'coverage' configuration to Makefile.
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1079 99668b35-9821-0410-8761-19e4c4f06640
2014-10-25 05:28:37 +00:00
Arseny Kapoulkine
4363e8a651 Remove redundant null pointer checks.
When removing a node or attribute, we know that the parent has at least one
node/attribute so a null pointer check is redundant.

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1078 99668b35-9821-0410-8761-19e4c4f06640
2014-10-25 03:17:55 +00:00
Arseny Kapoulkine
7b74531c1b tests: Fix test failure in PUGIXML_WCHAR_MODE
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1077 99668b35-9821-0410-8761-19e4c4f06640
2014-10-24 01:37:27 +00:00
Arseny Kapoulkine
546997683a tests: Add even more coverage tests
Also fix MSVC6 compilation (make convertions to function pointers explicit).

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1076 99668b35-9821-0410-8761-19e4c4f06640
2014-10-24 01:17:57 +00:00
Arseny Kapoulkine
903db8682a tests: Add more tests for better coverage
More tests for out-of-memory and other edge conditions

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1075 99668b35-9821-0410-8761-19e4c4f06640
2014-10-23 07:41:07 +00:00
Arseny Kapoulkine
bbd75fda46 tests: Improve test coverage
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1074 99668b35-9821-0410-8761-19e4c4f06640
2014-10-23 05:46:44 +00:00
Arseny Kapoulkine
21695288ec Fix compact mode 2014-10-21 23:32:44 -07:00
Arseny Kapoulkine
a55dfd3afa Merge branch 'master' into compact 2014-10-21 23:23:17 -07:00
Arseny Kapoulkine
4a7762af9d XPath: Optimize predicate evaluation
If the requested evaluation mode is not _all, we can use this mode for the
last predicate/filter expression and exit early.

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1073 99668b35-9821-0410-8761-19e4c4f06640
2014-10-22 03:33:37 +00:00
Arseny Kapoulkine
28d24e5b6c XPath: Use node pointers in step_push/step_fill
Using pointers instead of node/attribute objects allows us to use knowledge
about the tree to guarantee that pointers are not null. This results in
less null checks (10-20% speedup with optimizations enabled) and less
function calls (5x speedup with optimizations disabled).

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1072 99668b35-9821-0410-8761-19e4c4f06640
2014-10-22 03:31:09 +00:00
Arseny Kapoulkine
457522a836 Merge branch 'master' into compact 2014-10-20 22:24:25 -07:00
Arseny Kapoulkine
3c92704c19 tests: Fix PUGIXML_WCHAR_MODE compilation
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1071 99668b35-9821-0410-8761-19e4c4f06640
2014-10-21 03:38:30 +00:00
Arseny Kapoulkine
d7ac5e2e0c Merge branch 'master' into compact 2014-10-20 20:34:28 -07:00
Arseny Kapoulkine
7258aea09b tests: Assert on out-of-memory in tests
This should never happen but can improve debugging experience for
work-in-progress changes since that avoids memcpy() into negative memory
space (debugger can't backtrace from failed memcpy since it does not set
up the stack frame).

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1070 99668b35-9821-0410-8761-19e4c4f06640
2014-10-21 03:33:47 +00:00
Arseny Kapoulkine
7774cdd96e XPath: Make sure step_push is called with valid nodes
Some steps relied on step_push rejecting null inputs; this is no longer
the case. Additionally stepping now more rigorously filters null inputs.

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1069 99668b35-9821-0410-8761-19e4c4f06640
2014-10-21 03:33:37 +00:00
Arseny Kapoulkine
45b6315d99 tests: Add a coverage test for unspecified_bool
It's unfortunate that we can even do that...

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1068 99668b35-9821-0410-8761-19e4c4f06640
2014-10-20 01:00:56 +00:00
Arseny Kapoulkine
1b8b87904b XPath: Introduce _first/_any set evaluation modes
Sometimes when evaluating the node set we don't need the entire set and
only need the first element in docorder or any element. In the absence of
iterator support we can still use this information to short-circuit
traversals.

This does not have any effect on straightforward node collection queries,
but frequently improves performance of complex queries with predicates
etc. XMark benchmark gets 15x faster with some queries enjoying 100x
speedup on 10 Mb dataset due to a significant complexity improvement.

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1067 99668b35-9821-0410-8761-19e4c4f06640
2014-10-20 01:00:48 +00:00
Arseny Kapoulkine
2d4e549049 docs: Update XPath documentation
Add documentation for xpath_query::evaluate_node and change
select_single_node to select_node in documentation and samples.

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1066 99668b35-9821-0410-8761-19e4c4f06640
2014-10-19 07:34:02 +00:00
Arseny Kapoulkine
c3eb9c92a8 XPath: Rename xml_node::select_single_node to ::select_node
select_node is shorter and mistyping nodes as node or vice versa should
not lead to any issues since return types are substantially different.

select_single_node method still works and will be deprecated with an
attribute and removed at some point.

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1065 99668b35-9821-0410-8761-19e4c4f06640
2014-10-19 07:33:51 +00:00
Arseny Kapoulkine
f663558875 XPath: Introduce xpath_query::evaluate_node
This method is equivalent to xml_node::select_single_node. This makes
select_single_node faster in certain cases by avoiding an allocation and -
more importantly - paves the way for future step optimizations.

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1064 99668b35-9821-0410-8761-19e4c4f06640
2014-10-19 07:33:42 +00:00