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

Method simplify

basex-core/src/main/java/org/basex/query/expr/Switch.java:155–162  ·  view source on GitHub ↗

Simplifies a switch expression with identical branches. @return new or original expression

()

Source from the content-addressed store, hash-verified

153 * @return new or original expression
154 */
155 private Expr simplify() {
156 // only the default branch may be left at this stage
157 final Expr expr = groups[0].rtrn();
158 for(int g = groups.length - 1; g >= 1; g--) {
159 if(!expr.equals(groups[g].rtrn())) return this;
160 }
161 return expr;
162 }
163
164 /**
165 * Rewrites the switch to an if expression.

Callers 1

optMethod · 0.95

Calls 2

equalsMethod · 0.95
rtrnMethod · 0.80

Tested by

no test coverage detected