Tries to rewrite identical expressions to replicate. @param cc compilation context @throws QueryException query exception
(final CompileContext cc)
| 81 | * @throws QueryException query exception |
| 82 | */ |
| 83 | private void toReplicate(final CompileContext cc) throws QueryException { |
| 84 | final int el = exprs.length; |
| 85 | final ExprList list = new ExprList(el); |
| 86 | int s = 0, e = 0; |
| 87 | while(++e <= el) { |
| 88 | if(e == el || !exprs[e].equals(exprs[s])) { |
| 89 | if(e - s > 1) { |
| 90 | list.add(cc.replicate(exprs[s], Itr.get(e - s), info)); |
| 91 | cc.info(OPTMERGE_X, list.peek()); |
| 92 | } else { |
| 93 | while(s < e) list.add(exprs[s++]); |
| 94 | } |
| 95 | s = e; |
| 96 | } |
| 97 | } |
| 98 | exprs = list.finish(); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Tries to rewrite consecutive integers to range sequences. |