4 ms·
> 1. Avoid Turning Functions into async Whenever Possible > Consider the following example: Has the author benchmarked this? They are essentially replicating
by zamalek 1y ago
> 1. Avoid Turning Functions into async Whenever Possible
> Consider the following example:
Has the author benchmarked this? They are essentially replicating what the compiler does already: the compiler doesn't put each statement/expression into its own state, states occur on the boundaries of awaits.
- saghm 1y agoI wouldn't even feel confident in assuming that the compiler wouldn't inline the function they've defined, a one-liner that's only called from a single location. It wouldn't surprise me at all if the compiler produced exactly the same code for the two examples.
- surajrmal 1y agoI think he's trying to suggest not making a few function without any await statements async. He doesn't suggest implementing your own futures manually.
- zamalek 1y agoThat is not what is suggested by the code.