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

Method optimize

basex-core/src/main/java/org/basex/query/expr/constr/CTxt.java:32–48  ·  view source on GitHub ↗
(final CompileContext cc)

Source from the content-addressed store, hash-verified

30 }
31
32 @Override
33 public Expr optimize(final CompileContext cc) throws QueryException {
34 exprs = simplifyAll(Simplify.STRING, cc);
35
36 if(values(true, cc) && !(exprs[0] instanceof Str)) {
37 final byte[] value = atomValue(cc.qc, false);
38 exprs[0] = value != null ? Str.get(value) : Empty.VALUE;
39 }
40
41 final Expr expr = exprs[0];
42 final SeqType st = expr.seqType();
43 if(st.zero()) return cc.replaceWith(this, expr);
44
45 final boolean atom = !st.mayBeWrapped();
46 if(st.oneOrMore() && atom) exprType.assign(Occ.EXACTLY_ONE);
47 return this;
48 }
49
50 @Override
51 public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {

Callers

nothing calls this directly

Calls 10

getMethod · 0.95
seqTypeMethod · 0.95
zeroMethod · 0.95
mayBeWrappedMethod · 0.95
oneOrMoreMethod · 0.95
simplifyAllMethod · 0.80
replaceWithMethod · 0.80
valuesMethod · 0.45
atomValueMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected