Skip to content

Conversation

@AdamFrisby
Copy link

Reduces memory allocations and slightly increases performance

Reduces memory allocations and slightly increases performance
Translation = SubInstance._sensor.Translation;

float sensitivity = Application.isPlaying ? Settings.PlayTransSens : Settings.TransSens[Settings.CurrentGear];
return (SubInstance._sensor == null ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing SubInstance._sensor == null twice. Can be put at the top of the method with an early return.

Rotation = SubInstance._sensor.Rotation;

float sensitivity = Application.isPlaying ? Settings.PlayRotSens : Settings.RotSens;
return (SubInstance._sensor == null ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, testing SubInstance._sensor == null twice. Same solution.

public override Vector3 GetTranslation() {
public override Vector3 GetTranslation()
{
if (SubInstance._sensor != null && Translation == null)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Match the indent of the rest of this method, especially since you're not using { } (which I would highly recommend using).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a real-world example of why you should really use curly braces (TLDR: major security failure in Apple's SSL).
https://blog.codecentric.de/en/2014/02/curly-braces/

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