chore: Small performance improvements#3683
Merged
EmandM merged 14 commits intodevelop-2.0.0from Oct 2, 2025
Merged
Conversation
- Merge looped Add calls into AddRange - Optimize empty string checks - Merge position & rotation calls into one - Short circuit operators for bools - Optimize string generation - Use native Count instead of LINQ
… into fix/performance-optimizations
jabbacakes
approved these changes
Sep 18, 2025
Member
NoelStephensUnity
left a comment
There was a problem hiding this comment.
Two minor areas to review over.
The rest looks good to me. 👍
| m_ServerAddressProperty = connectionDataProperty.FindPropertyRelative(nameof(UnityTransport.ConnectionAddressData.Address)); | ||
| m_ServerPortProperty = connectionDataProperty.FindPropertyRelative(nameof(UnityTransport.ConnectionAddressData.Port)); | ||
| m_OverrideBindIpProperty = connectionDataProperty.FindPropertyRelative(nameof(UnityTransport.ConnectionAddressData.ServerListenAddress)); | ||
| connectionDataProperty.FindPropertyRelative(nameof(UnityTransport.ConnectionAddressData.ServerListenAddress)); |
Member
There was a problem hiding this comment.
It seems that this last adjusted line is not used... and the property found is not being assigned to anything.
Is there a reason to keep this line?
Member
Author
There was a problem hiding this comment.
Thanks for catching that. The m_OverrideBindIpProperty was never being used anywhere so I pulled it out, but obviously not very thoroughly
|
|
||
| ClientPositionVisual.transform.position = m_ClientPosition; | ||
| ClientPositionVisual.transform.rotation = InLocalSpace ? transform.localRotation : transform.rotation; | ||
| var rotation = InLocalSpace ? transform.localRotation : transform.rotation; |
Member
There was a problem hiding this comment.
This still needs to use the m_ClientPosition.
Member
Author
There was a problem hiding this comment.
It's using m_ClientPosition on the next line down 😄
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
@smitdylan2001 found and fixed some small performance improvements, which do not change any functionality. Especially the position and rotation calls and LINQ call removals are very helpful for performance
Addcalls onList<T>variables intoAddRangeAddRangewill ensure the list is only extended once.String.Lengthis faster than usingEquals(C# docs reference)SetPositionAndRotationhas a small performance improvement (docs).Count()uses LINQ and has a cost..Countdoes the same thing without the LINQ cost.StringBuilder.AppendJoinrather thanStringBuilder.Append(String.Joincontinues: #3680
Jira ticket
n/a: contribution from external user
Changelog
Documentation
SetPositionAndRotationrather than setting the two independentlyTesting & QA (How your changes can be verified during release Playtest)
Does the change require QA team to:
Review automated tests?Execute manual tests?Provide feedback about the PR?If any boxes above are checked the QA team will be automatically added as a PR reviewer.
Backports
These are small performance improvements so they do not need to be backported.