micropython / stm32lib

STM32 Cube library - CMSIS and HAL for F4, F7 and L4 microcontrollers
63 stars 71 forks source link

Pass USB_OTG_CfgTypeDef by reference. #16

Closed dlech closed 2 years ago

dlech commented 2 years ago

This updates all HAL libraries to pass USB_OTG_CfgTypeDef by reference. USB_OTG_CfgTypeDef is a large struct that is being passed by value which uses extra stack and bigger code due to the extra copy of the struct.

dpgeorge commented 2 years ago

Thanks, this looks like a good optimisation. It might make it harder to update to newer HAL versions, but I guess we can deal with that when needed.

Would it be better to pass it in as a const USB_OTG_CfgTypeDef*? Then it's guaranteed the caller won't change the struct, which retains semantics with pass-by-value.

dlech commented 2 years ago

Would it be better to pass it in as a const USB_OTG_CfgTypeDef*? Then it's guaranteed the caller won't change the struct, which retains semantics with pass-by-value.

Yes, that sounds like a good idea.

dlech commented 2 years ago

I have updated with the suggested change.

dpgeorge commented 2 years ago

Thanks for updating. Merged in 5039e299bb92a79a777a97548f5722fd94c6425c through f0ff2b2346877fcc7841423a9cc930fcde11dfe1