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

Method optimize

basex-core/src/main/java/org/basex/query/expr/CmpR.java:125–139  ·  view source on GitHub ↗
(final CompileContext cc)

Source from the content-addressed store, hash-verified

123 }
124
125 @Override
126 public Expr optimize(final CompileContext cc) throws QueryException {
127 expr = expr.simplifyFor(Simplify.NUMBER, cc);
128
129 final SeqType st = expr.seqType();
130 single = st.zeroOrOne() && !st.mayBeWrapped();
131
132 // position() = .1e0 → false()
133 if(Function.POSITION.is(expr)) {
134 final long mn = Math.max((long) Math.ceil(min), 1), mx = (long) Math.floor(max);
135 return cc.replaceWith(this, IntPos.get(mn, mx, info));
136 }
137
138 return expr instanceof Value ? cc.preEval(this) : this;
139 }
140
141 @Override
142 public Bln item(final QueryContext qc, final InputInfo ii) throws QueryException {

Callers 1

getMethod · 0.45

Calls 10

zeroOrOneMethod · 0.95
mayBeWrappedMethod · 0.95
getMethod · 0.95
replaceWithMethod · 0.80
seqTypeMethod · 0.65
isMethod · 0.65
simplifyForMethod · 0.45
maxMethod · 0.45
floorMethod · 0.45
preEvalMethod · 0.45

Tested by

no test coverage detected