road-to-orleans icon indicating copy to clipboard operation
road-to-orleans copied to clipboard

Use valuetask instead of Task.FromResult

Open mikescandy opened this issue 3 years ago • 1 comments

A trivial change to introduce ValueTask instead of Task.FromResult. In this case being completely synchronous, the code shouldn't allocate anything, instead of allocating one Task.

If we agree on the changes, I'll propagate them across the various solutions

mikescandy avatar Oct 18 '21 13:10 mikescandy

Very nice, let's apply this 👍

Some reading material for those interested:

  • https://blog.marcgravell.com/2019/08/prefer-valuetask-to-task-always-and.html
  • https://devblogs.microsoft.com/dotnet/understanding-the-whys-whats-and-whens-of-valuetask

PiotrJustyna avatar Oct 18 '21 16:10 PiotrJustyna