Skip to content

Commit

Permalink
remove unnecessary list allocs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored and oskardudycz committed May 19, 2024
1 parent 5706cbb commit 499277c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Core.Testing/TestWebApplicationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected override IHost CreateHost(IHostBuilder builder)
}

public void PublishedExternalEventsOfType<TEvent>() where TEvent : IExternalEvent =>
externalEventProducer.PublishedEvents.OfType<TEvent>().ToList().Should().NotBeEmpty();
externalEventProducer.PublishedEvents.OfType<TEvent>().Should().NotBeEmpty();

public Task PublishInternalEvent<TEvent>(TEvent @event, CancellationToken ct = default) where TEvent : notnull =>
PublishInternalEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CancellationToken ct

var currentSummary = await getCurrentSummary(ToStreamId(@event.ProductId), ct)
?? ProductRelationshipsCalculated.Default();

var relatedProducts = Expand(@event.RelatedProducts).ToList();

foreach (var currentRel in currentSummary.Relationships)
Expand All @@ -52,7 +52,7 @@ CancellationToken ct
relatedProducts
.Select(relationship =>
new ProductRelationshipsInBaskets(relationship, 1)
).ToList()
)
);

return currentSummary with { Relationships = result, BasketsCount = currentSummary.BasketsCount + 1 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ FROM events
JsonConvert.DeserializeObject(
@event.data,
Type.GetType(@event.type, true)!
))
.ToList();
));
}

private void CreateStreamsTable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ FROM events
JsonConvert.DeserializeObject(
@event.data,
Type.GetType(@event.type, true)!
))
.ToList();
));
}

private void CreateStreamsTable()
Expand Down
3 changes: 1 addition & 2 deletions Workshops/BuildYourOwnEventStore/08-Snapshots/EventStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ FROM events
JsonConvert.DeserializeObject(
@event.data,
Type.GetType(@event.type, true)!
))
.ToList();
));
}

private void CreateStreamsTable()
Expand Down

0 comments on commit 499277c

Please sign in to comment.