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

Method toReplicate

basex-core/src/main/java/org/basex/query/expr/List.java:83–99  ·  view source on GitHub ↗

Tries to rewrite identical expressions to replicate. @param cc compilation context @throws QueryException query exception

(final CompileContext cc)

Source from the content-addressed store, hash-verified

81 * @throws QueryException query exception
82 */
83 private void toReplicate(final CompileContext cc) throws QueryException {
84 final int el = exprs.length;
85 final ExprList list = new ExprList(el);
86 int s = 0, e = 0;
87 while(++e <= el) {
88 if(e == el || !exprs[e].equals(exprs[s])) {
89 if(e - s > 1) {
90 list.add(cc.replicate(exprs[s], Itr.get(e - s), info));
91 cc.info(OPTMERGE_X, list.peek());
92 } else {
93 while(s < e) list.add(exprs[s++]);
94 }
95 s = e;
96 }
97 }
98 exprs = list.finish();
99 }
100
101 /**
102 * Tries to rewrite consecutive integers to range sequences.

Callers 1

optimizeMethod · 0.95

Calls 7

getMethod · 0.95
addMethod · 0.65
infoMethod · 0.65
equalsMethod · 0.45
replicateMethod · 0.45
peekMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected