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

tweak(scripting/lua): speed up lua event serialization. #3006

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

icy4471
Copy link

@icy4471 icy4471 commented Dec 15, 2024

If there are no event handlers for the event, there is no need to unpack or set the source as they will never be used.

Goal of this PR

Significantly speeds up event serialization when there are no handlers available.

How is this PR achieving the goal

By returning early when there are no event handlers available.

This PR applies to the following area(s)

FiveM, ScRT: Lua

Successfully tested on

Game builds: b3095

Platforms: Windows, Linux

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

If there are no event handlers for the event, there is no need to unpack or set the source as they will never be used.
@github-actions github-actions bot added RedM Issues/PRs related to RedM ScRT: Lua Issues/PRs related to the Lua scripting runtime triage Needs a preliminary assessment to determine the urgency and required action labels Dec 15, 2024
@thelindat
Copy link
Contributor

Worth noting that this function is only triggered in functions which have registered the event previously, so this only helps with removed events. Possibly worth being able to remove resources from the event registry altogether?

@AvarianKnight
Copy link
Contributor

Another thing to note here is msgpack_unpack should be called after the net checks.

move msgpack_unpack to after the net checks, as it isn't used until after.
@github-actions github-actions bot added invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Requires changes before it's considered valid and can be (re)triaged RedM Issues/PRs related to RedM ScRT: Lua Issues/PRs related to the Lua scripting runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants