Mr-Markus / ZigbeeNet

A .NET Standard library for working with ZigBee
Eclipse Public License 1.0
131 stars 47 forks source link

avoid return await #81

Closed nicolaiw closed 4 years ago

nicolaiw commented 4 years ago

Like here https://github.com/Mr-Markus/ZigbeeNet/blob/develop/libraries/ZigBeeNet/ZigBeeNetworkManager.cs#L992 we should avoid to call "return await" if possible as the compile will generate a state machine. Just return the Task direcly. In most cases it is not necessary to call await when there is nothing to do after awaiting the task. (It might by when combined with using)

nicolaiw commented 4 years ago

I made a quick example. Have a look at the difference IL code.

https://sharplab.io/#v2:CYLg1APgAgTAjAWAFBQAwAIpwKwG5nJQDMmM6AwugN7Lp3q30AOATgJYBuAhgC4CmmAGzoASgFcAdgEEAzgE8JAYwD6cABQBKRnRpJ6+zAHYhAOnES1m9AF4AfNQC+G/HvoPtDV3VadeAqAAcQqKSsgoqMJoeugb0UACcpuaWGjb2VE4u+u5IDkA

spudwebb commented 4 years ago

fixed in PR #90

Mr-Markus commented 4 years ago

Thx for quick implementation