Mr-Markus / ZigbeeNet

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

Replacement of DoubleByte by ushort #135

Closed oblaise closed 3 years ago

oblaise commented 3 years ago

The purpose of this PR is to remove the DoubleByte class and replace its usage by ushort in the ZigBeeNet.Hardware.TI.CC2531 library.

Using a class for storing 2 bytes of data has an impact on performance (heap allocation for each new object, additional calls, garbage collection). By replacing this class and using directly ushort with a few helper functions that will probably be inlined by the compiler most of the time you will lower memory impact and improve performance.

As the DoubleByte class wasn't used anywhere else in the repository I removed it from the code to prevent usage in the future.

Mr-Markus commented 3 years ago

@oblaise Thanks for your PR and well understanding explanation. We need to seperate LSB and MSB, but with your solution it is still avalible and technically better