angry-goose-initiative / wiki

AGI Wiki
0 stars 0 forks source link

Improve Word methods #27

Closed nickchan2 closed 7 months ago

nickchan2 commented 8 months ago

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.

JZJisawesome commented 8 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. :)

nickchan2 commented 8 months ago

After looking into this a bit more, I've come to the following conclusions:

Therefore, I think the only thing we really should do for this is to put the implementation of all Word methods in the header

JZJisawesome commented 8 months ago

Awesome, sounds good to me!

JZJisawesome commented 7 months ago

Closing since the PR was merged :)