-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid using std::function for performance #106
Conversation
You still have to deduce the F parameter, so we can just call it with a single template parameter as before? I expect it not to work as of now, since dispatch has 2 template parameters, where in all the code we only provide one |
Odd.. the person that says it's a 20% improvement did not test with the deduction piece. Which is why I don't think that matters. I mainly made this PR to implement the performance bit of things, but if you have an idea for how to implement the deduction I'd love to hear it. |
Maybe @Chlorie can help us implement it, as we both hit a solid brick wall on trying to get the deduction working... |
@LovelySanta The "F" parameter is deduced by the compiler, so it can be ignored. We care about parameter "T", which is the parameter that the user already provides, so the code in this pull request is basically complete(The optimization). I'm a bit skeptical about the deduction piece though. If I understand correctly, the idea is to automatically deduce parameter "T"? Because if that's the case, it would seem nicer to have to explicitly declare "T" to confirm "I want this type of event to be handled by this function". |
I was busy doing something else recently so I didn't respond to this pull request, my fault. |
After some trial and error I found that it's really hard to do the full type deduction (let the compiler to deduce T) when using generic function objects (function pointers are easy, non-generic lambdas are easy, but generic function objects like the return value of std::bind are hard). If this is not really needed, like what @ilikenoodles2 said, the solution in this PR is good enough. |
Now that I look at it, it might indeed be more readable to supply T. I'll approve as it is, no need to deduce T. |
Added the comment. |
LGTM |
Avoiding the usage of std::function in event dispatcher for performance. This has an 20%+ improvement in speed. You can read more about this via issue #85.
Full credit to @Chlorie for this.
This PR was never made so I've decided to make it.
This resolves #85.