Skip to content
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

Refactored the injection module to be more efficient #570

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

An00nymushun
Copy link

Most importantly, I removed the part where it scans through all the injections twice, to find all the ones that match the called method.
I also made the debugging code a bit better by only showing hooks that actually ran and added better performance measurements by using perf_hooks.

@cyyynthia
Copy link
Collaborator

Considering v2 is in maintenance only, there's not much interest in adding new features or doing anything much than base maintenance and ensure it still works with Discord updates.

While scanning twice is not really ideal, it's unlikely there'll ever be enough injections for it to have a real, noticeable impact. Moreover, perf_hooks is only precise up to milliseconds, whereas hrtime is outputting nanoseconds which is very useful for cases where we have sub-millisecond runtimes (which can easily happen with small injections on high end machines). There's on top of that code-style issues.

Considering all the above and current state of v2 while v3 is indev, this pr will probably not be merged, the benefits being too minor in this context.

@An00nymushun
Copy link
Author

I didn't know hrtime was in nanoseconds, but both are high precision, it's just that the performance one is multiplied so it's milliseconds plus fractions.

I don't get what you mean by code-style issues and where is the code for v3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants