Closed nickchan2 closed 7 months ago
We can add new templated methods but I think we should retain the old ones.
I don't want to refactor existing code, rather we should just encourage the templated function's use in future code.
The class / namespace changes/renames from earlier don't affect behaviour so I was okay with it, but refactoring existing function calls is dangerous. Besides, I already have those functions declared as inline
so there likely wouldn't be that big of a difference in performance regardless. We could add __attribute__ ((always_inline))
to be absolutely sure inlining does occur if you wish.
Adding these as secondary functions alongside the current ones sounds good to me though. :)
After looking into this a bit more, I've come to the following conclusions:
inline
keyword is generally redundant. From cppreference:
A function defined entirely inside a class/struct/union definition, whether it's a member function or a non-member friend function, is implicitly an inline function
__attribute__ ((always_inline))
is also likely overkill. These days, the compiler usually knows bestTherefore, I think the only thing we really should do for this is to put the implementation of all Word
methods in the header
Awesome, sounds good to me!
Closing since the PR was merged :)
These functions are used very frequently, so we should optimize them as much as possible, especially since most of the time, their parameters are known at compile time.
We should use template parameters since the parameters are always known at compile time and this will allow us to use static assertions on the parameters instead of run time assertions.