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

Method optimize

basex-core/src/main/java/org/basex/query/expr/gflwor/Let.java:65–89  ·  view source on GitHub ↗
(final CompileContext cc)

Source from the content-addressed store, hash-verified

63 }
64
65 @Override
66 public Let optimize(final CompileContext cc) throws QueryException {
67 // skip redundant type check
68 if(!scoring && expr instanceof TypeCheck) {
69 if(var.declType != null && var.declType.instanceOf(expr.seqType()) ||
70 var.adoptCheck(expr.seqType())) {
71 cc.info(OPTTYPE_X, this);
72 expr = ((TypeCheck) expr).expr;
73 }
74 }
75 // coerce at compile time
76 if(expr instanceof final Value value) {
77 expr = var.checkType(value, cc.qc, cc);
78 }
79
80 // assign type to clause and variable
81 if(scoring) {
82 var.expr(Dbl.ZERO);
83 } else {
84 adoptType(expr);
85 var.expr(expr);
86 }
87 var.refineType(seqType(), size(), cc);
88 return this;
89 }
90
91 @Override
92 public Let copy(final CompileContext cc, final IntObjectMap<Var> vm) {

Callers 5

compileMethod · 0.45
inlineMethod · 0.45
refMethod · 0.45
functionMethod · 0.45
finishMethod · 0.45

Calls 9

adoptCheckMethod · 0.80
adoptTypeMethod · 0.80
instanceOfMethod · 0.65
seqTypeMethod · 0.65
infoMethod · 0.65
sizeMethod · 0.65
checkTypeMethod · 0.45
exprMethod · 0.45
refineTypeMethod · 0.45

Tested by

no test coverage detected