This little change increase the size and alignment guarantees of the
storage space used in FunctionPointerbase to store member function
pointers.
As a side effect, it also reduce the size of the FunctionPointerBase
class from 28 bytes to 20.
It is important to note that it is still possible to decrease the size of FunctionPointerBase:
Get rid of virtual function in FunctionPointerBase (this change can save 4 bytes). It does not make sense to use virtual member functions just for the clear member function:
Does it have to be a polymorphic call ?
I tried to track use cases of FunctionPointerBase::clear in a polymorphic way I didn't find any result in our sources, I would be glad if someone can provide me a use case.
Even if the clear function should be polymorphic, the interface is not correctly designed because overrides of clear should always call FunctionPointerBase::clear, a non virtual interface is much better in this case.
Exploit the fact that we run mbed os on ARM processors which use ARM ABI ... where member functions are well defined. This other change can save (I think) 4 bytes.
This little change increase the size and alignment guarantees of the storage space used in
FunctionPointerbase
to store member function pointers.As a side effect, it also reduce the size of the
FunctionPointerBase
class from 28 bytes to 20.It is important to note that it is still possible to decrease the size of
FunctionPointerBase
:FunctionPointerBase
(this change can save 4 bytes). It does not make sense to use virtual member functions just for theclear
member function:FunctionPointerBase::clear
in a polymorphic way I didn't find any result in our sources, I would be glad if someone can provide me a use case.clear
should always callFunctionPointerBase::clear
, a non virtual interface is much better in this case.