Refactor variant_call.cpp to make better use of templates, eliminating one layer of abstraction
#104627
+234
−374
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR simplifies some functions in
variant_call.cpp. In particular:#define METHOD_CLASSand others are replaced with templatedregister_methodand others.vc_get_argument_typeandvc_get_argument_countare replaced withvc_get_argument_types.The goal of this PR is to reduce complexity in the file by:
#definewrapped code into 'real' code, making it easier to edit and understand.My ulterior motive is to eventually propose exposing this API to GDExtension. But this PR should be defendable without this motive :)
Benchmarks
I do not expect either an improvement or regression, but it should be tested to be sure about it.
I benchmarked editor launch as a quick and dirty entry test for this:
I'm taking this as no difference (change within expected fluctuations).
I also benchmarked the unit tests:
The difference is similar as before, so probably within expected fluctuations.
A better test would be benchmarking actual calls (
call,validated_callandptrcall). I might do this, but I'd also appreciate if someone else stepped up!Size Decrease
As a side effect, the size of the final binary shrinks by about
0.8mb(0.5%).I checked with bloaty about this, and the decrease is indeed caused by the templates taking up less space than the structs we had before: