@@ -20,7 +20,6 @@ public final class ArrayJoin extends ArrayFn {
2020 @ Override
2121 public XQArray item (final QueryContext qc , final InputInfo ii ) throws QueryException {
2222 final Expr arrays = arg (0 );
23- final Item separator = arg (1 ).item (qc , info );
2423
2524 // if possible, retrieve single item
2625 if (arrays .seqType ().zeroOrOne ()) {
@@ -31,24 +30,18 @@ public XQArray item(final QueryContext qc, final InputInfo ii) throws QueryExcep
3130 Item item = iter .next ();
3231 if (item == null ) return XQArray .empty ();
3332
34- final ValueList sep = new ValueList ();
35- if (!separator .isEmpty ()) {
36- for (final Value value : toArray (separator ).iterable ()) sep .add (value );
37- }
38-
3933 final ArrayBuilder ab = new ArrayBuilder (qc );
40- for (final Value value : toArray (item ).iterable ()) ab .add (value );
41- while ((item = qc .next (iter )) != null ) {
42- for (final Value value : sep ) ab .add (value );
34+ do {
4335 for (final Value value : toArray (item ).iterable ()) ab .add (value );
44- }
36+ } while ((item = qc .next (iter )) != null );
37+
4538 return ab .array (this );
4639 }
4740
4841 @ Override
4942 protected Expr opt (final CompileContext cc ) throws QueryException {
50- final Expr arrays = arg (0 ), separator = arg ( 1 ) ;
51- final SeqType ast = arrays .seqType (), sst = separator . seqType () ;
43+ final Expr arrays = arg (0 );
44+ final SeqType ast = arrays .seqType ();
5245
5346 if (ast .type instanceof ArrayType ) {
5447 // remove empty entries
@@ -64,9 +57,7 @@ protected Expr opt(final CompileContext cc) throws QueryException {
6457 final SeqType st = arg (0 ).seqType ();
6558 if (st .one ()) return arg (0 );
6659
67- final Type type = sst .type instanceof ArrayType ? st .type .union (sst .type ) :
68- sst .zero () ? st .type : null ;
69- if (type != null ) exprType .assign (type );
60+ exprType .assign (st .type );
7061 }
7162 return this ;
7263 }
0 commit comments