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

CacheExpensiveCallsAnalyzer #44

Closed
wants to merge 5 commits into from
Closed

Conversation

AnBucyk
Copy link
Contributor

@AnBucyk AnBucyk commented Mar 11, 2020

Fixes #22

Checklist

  • I have read the Contribution Guide ;
  • There is an approved issue describing the change when contributing a new analyzer or suppressor ;
  • I have added tests that prove my fix is effective or that my feature works ;
  • I have added necessary documentation (if appropriate) ;

Short description of what this resolves:

Detects expensive calls to GetComponents and Camera.main in Update and FixedUpdate and provides a codefix to cache the results instead.

TODO

  • Detect expensive calls to GetComponent in Update and FixedUpdate
  • Detect expensive access to Camera.main in Update and FixedUpdate
  • Refactor similar code in CacheExpensiveCalls.cs to have one path before branching to InvocationExpression and MemberAccessExpression
  • Create helper class for shared code between analyzers
  • Provide a code fix that caches these calls in Awake instead
  • Ensure the code fix wont write duplicated code if the expensive call is already cached, for whatever reason. That would break user's build.
  • Write tests
  • Write docs

@therealjohn
Copy link
Member

Another expensive call is VectorN.Distance functions. The VectorN.SqrMagnitude methods could be used instead. Would this tip be a candidate for here or a new request?

@sailro sailro changed the base branch from master to main July 14, 2020 00:20
@sailro sailro closed this Jul 23, 2020
@jbevain jbevain deleted the cache-expensive-calls-analyzer branch January 23, 2021 01:18
@bestknighter
Copy link

bestknighter commented May 12, 2022

Was this merged? If so, the issue #22 needs to be marked as solved. If not, I believe the issue would be stale, right?

@smitdylan2001
Copy link

Another expensive call is VectorN.Distance functions. The VectorN.SqrMagnitude methods could be used instead. Would this tip be a candidate for here or a new request?

When benchmarking in recent versions this actually is not the case

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.

Cache expensive calls
5 participants