Some minor reworks to use TryGetComponent in every-frame pointer code#10315
Merged
Conversation
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
per @keveleigh, the alloc only occurs in the editor. this pattern should be utilized going forward (v3). given 2018 does not contain the TryGetComponent API, it feels like a more risky change for the v2 code base |
395c32d to
8aac939
Compare
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Contributor
Author
With the goal of trying to improve performance in as many code paths as possible (especially with regards to pointers and focus!), I think we should reevaluate taking this change for 2.8. I've retargeted the branch to ensure our tests continue to succeed there. |
8aac939 to
ae08c53
Compare
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
david-c-kline
approved these changes
May 19, 2022
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.
Overview
While digging into #10310, I noticed a couple spots where
GetComponenton objects without the corresponding component were both costly and caused allocations. Unity 2019 introducedTryGetComponent, which helps reduce those side effects.Before:


After:
