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

Method optimize

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

Source from the content-addressed store, hash-verified

38 }
39
40 @Override
41 public Expr optimize(final CompileContext cc) throws QueryException {
42 exprs = simplifyAll(Simplify.STRING, cc);
43 if(values(false, cc)) return cc.preEval(this);
44
45 // swap operands
46 if(swap()) {
47 cc.info(OPTSWAP_X, this);
48 Collections.reverse(Arrays.asList(exprs));
49 op = op.swap();
50 }
51
52 Expr expr = emptyExpr();
53 if(expr == this) expr = toGeneral(cc, true);
54 if(expr == this) expr = opt(cc);
55 if(expr == this) {
56 // restrict type
57 final SeqType st1 = exprs[0].seqType(), st2 = exprs[1].seqType();
58 if(st1.oneOrMore() && !st1.mayBeWrapped() && st2.oneOrMore() && !st2.mayBeWrapped()) {
59 exprType.assign(Occ.EXACTLY_ONE);
60 }
61 }
62 return cc.replaceWith(this, expr);
63 }
64
65 @Override
66 public Expr simplifyFor(final Simplify mode, final CompileContext cc) throws QueryException {

Callers 1

toGeneralMethod · 0.45

Calls 14

toGeneralMethod · 0.95
oneOrMoreMethod · 0.95
mayBeWrappedMethod · 0.95
simplifyAllMethod · 0.80
emptyExprMethod · 0.80
replaceWithMethod · 0.80
infoMethod · 0.65
reverseMethod · 0.65
seqTypeMethod · 0.65
valuesMethod · 0.45
preEvalMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected