MCPcopy Create free account
hub / github.com/BaseXdb/basex / merge

Method merge

basex-core/src/main/java/org/basex/query/expr/path/Test.java:84–101  ·  view source on GitHub ↗

Merges a test into the union test list. @param test test to be merged @param list list

(final Test test, final List<Test> list)

Source from the content-addressed store, hash-verified

82 * @param list list
83 */
84 private static void merge(final Test test, final List<Test> list) {
85 final int ls = list.size();
86 for(int l = 0; l < ls; l++) {
87 final Test t = list.get(l);
88 // skip URI-based comparisons (may not be assigned yet at parse time)
89 if(test instanceof final NameTest ntest && t instanceof final NameTest nt && (
90 ntest.scope == NameTest.Scope.URI || nt.scope == NameTest.Scope.URI)) continue;
91 // * union A
92 if(test.instanceOf(t)) return;
93 // A union * → *
94 if(t.instanceOf(test)) {
95 list.set(l, test);
96 return;
97 }
98 }
99 // A union B → (A|B)
100 list.add(test);
101 }
102
103 /**
104 * Optimizes the test.

Callers 1

getMethod · 0.95

Calls 6

instanceOfMethod · 0.95
sizeMethod · 0.65
getMethod · 0.65
instanceOfMethod · 0.65
setMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected