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

Performance improvements to Physics.Common.WeenieObject #4212

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

Conversation

FlaggAC
Copy link
Contributor

@FlaggAC FlaggAC commented Aug 11, 2024

Entire set of fields can be marked as readonly, as it never changes outside of the constructor.
Reduces unnecessary reflection operations by pre-fetching them during constructor
Changes WeenieObject to a sealed class to guarantee immutability
Immutability allows a shared DummyObject to be used by PhysicsObjs which do not have a weenie.

The reflection calls are made frequently by PhysicsObj.FindObjCollisions(Transition), which is a very frequently-called method, so this is expected to improve performance. The 'is' operator is fast by reflection standards, but there is still some overhead with it, which should not be ignored considering the high frequency of the method calls.

ID and UpdateTime are commented out because they are never used.

Entire set of fields can be marked as readonly, as it never changes outside of the constructor.

Reduces unnecessary reflection operations by pre-fetching them during constructor

Changes WeenieObject to a sealed class to guarantee immutability

Immutability allows a shared DummyObject to be used by PhysicsObjs which do not have a weenie.
@gmriggs gmriggs requested a review from Mag-nus August 11, 2024 07:51
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.

1 participant