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

optimize AreAllies #22

Merged
merged 1 commit into from
Oct 21, 2022
Merged

optimize AreAllies #22

merged 1 commit into from
Oct 21, 2022

Conversation

noreenko
Copy link

Improvements

  • Reduces comparisons by an average of 1 per call to AreAllies.
  • Fixes error if first.Faction is null and second.Faction is not.

Possible Regression

  • The case of first == second now has an Unhandled Exception when first and second == null. I believe first and second are never supposed to be null as the throw this exception when first or second are null but not both. If this is a regression, adding if(first == second) return true; as the first line will fix and it will still be on average faster (at worst the same) as the previous function.

Sorry if this is an unnecessary PR. I'm trying to introduce myself to forking and modding Rimworld while practicing some C#.

image

@jecrell
Copy link
Owner

jecrell commented Oct 21, 2022

Apologies this took so long to address. It will be included. Thank you for your assistance

@jecrell jecrell merged commit a636a8c into jecrell:master Oct 21, 2022
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.

2 participants