-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat: run duplicate pre-hooks just once #31
Conversation
bff3964
to
d154a96
Compare
540df6f
to
f298cfe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for also collapsing the redundant internal functions that were re-used for permitted call hooks.
f298cfe
to
1869bd4
Compare
Thanks for the simplification! Do you think if it's still worth of storing duplicated preHooks if they're only run once now? |
@huaweigu Yes, but it can be simplified further to reduce costs. There is still the possibility of the magic values like |
Thanks, I was thinking even if |
Correct, the result of running them would be the same. When uninstalling though, you'd want to make sure that the plugin you're uninstalling applied the last instance of that hook to that function before removing it. If two plugins applied that hook, and one of them is uninstalled, you'd still want to keep that hook applied instead of removing it. |
Thank you Jay for your explanation. It makes sense for |
With #29, which removes the ability for plugins to depend on other plugin's hooks, the only cases where there will be duplicate hooks applied to a selector are:
ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY
to the same selector.This makes running duplicate pre-hooks multiple times unnecessary.
Note that duplicate post-hooks may still run multiple times if they are attached to different pre-hooks, since the pre-hook return data that are passed to them may be different. And since they will be configured from the same plugin, any duplicate runs will be intentional.
Edit: to expand, in cases where a plugin might want to apply
{preHook: A, postHook: B}
and{preHook: A: postHook: C}
to a selector, AND they wantA
to be executed twice and not once, this can be addressed by collapsing the logic inB
andC
into a single post-hook.