Skip to content

Commit

Permalink
=str Optimize concat for javadsl.Source.empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
He-Pin committed Dec 23, 2023
1 parent 873868c commit 781b122
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,17 @@ public void apply(String elem) {
assertEquals(Arrays.asList("A", "B", "C", "D", "E", "F"), output);
}

@Test
public void mustBeAbleToConcatEmptySource() {
Source.from(Arrays.asList("A", "B", "C"))
.concat(Source.empty())
.runWith(TestSink.probe(system), system)
.ensureSubscription()
.request(3)
.expectNext("A", "B", "C")
.expectComplete();
}

@Test
public void mustBeAbleToUseConcatAll() {
final Source<Integer, NotUsed> sourceA = Source.from(Arrays.asList(1, 2, 3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3302,7 +3302,7 @@ trait FlowOps[+Out, +Mat] {

private def internalConcat[U >: Out, Mat2](that: Graph[SourceShape[U], Mat2], detached: Boolean): Repr[U] =
that match {
case source if source eq Source.empty => this.asInstanceOf[Repr[U]]
case source if TraversalBuilder.isEmptySource(source) => this.asInstanceOf[Repr[U]]
case other =>
TraversalBuilder.getSingleSource(other) match {
case OptionVal.Some(singleSource) =>
Expand Down

0 comments on commit 781b122

Please sign in to comment.