From a5cda443947bdeb68b24a4cc54177a26c15a022a Mon Sep 17 00:00:00 2001
From: Michael Krisper <michael.krisper@tugraz.at>
Date: Tue, 19 Apr 2022 17:15:58 +0200
Subject: [PATCH] GearshiftPosition: Minor refactoring (expression bodies)

---
 .../VectoCommon/Models/GearshiftPosition.cs   | 28 +++++--------------
 .../SimulationComponent/Impl/ATGearbox.cs     |  4 +--
 2 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/VectoCommon/VectoCommon/Models/GearshiftPosition.cs b/VectoCommon/VectoCommon/Models/GearshiftPosition.cs
index c4c246034e..9de4158dae 100644
--- a/VectoCommon/VectoCommon/Models/GearshiftPosition.cs
+++ b/VectoCommon/VectoCommon/Models/GearshiftPosition.cs
@@ -18,28 +18,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			TorqueConverterLocked = torqueConverterLocked;
 		}
 
-		public override string ToString()
-		{
-			return Name;
-		}
+		public override string ToString() => Name;
 
-		public string Name => $"{Gear}{(Gear == 0 ? "" : (TorqueConverterLocked.HasValue ? (TorqueConverterLocked.Value ? "L" : "C") : ""))}";
+		public string Name => 
+			$"{Gear}{(Gear == 0 || TorqueConverterLocked is null ? "" : (TorqueConverterLocked.Value ? "L" : "C"))}";
 
 		public bool Engaged => Gear != 0;
 
-		public override bool Equals(object x)
-		{
-			var other = x as GearshiftPosition;
-			if (other == null)
-				return false;
-
-			return other.Gear == Gear && other.TorqueConverterLocked == TorqueConverterLocked;
-		}
+		public override bool Equals(object x) =>
+			x is GearshiftPosition other && other.Gear == Gear && other.TorqueConverterLocked == TorqueConverterLocked;
 
-		public override int GetHashCode()
-		{
-			return Name.GetHashCode();
-		}
+		public override int GetHashCode() => Name.GetHashCode();
 
 		public static bool operator >(GearshiftPosition p1, GearshiftPosition p2)
 		{
@@ -76,10 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 		}
 
 
-		public bool IsLockedGear()
-		{
-			return !TorqueConverterLocked.HasValue || TorqueConverterLocked.Value;
-		}
+		public bool IsLockedGear() => !TorqueConverterLocked.HasValue || TorqueConverterLocked.Value;
 	}
 
 	public class GearList : IEnumerable<GearshiftPosition>
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs
index 40aea8de9f..5e899f7b8e 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs
@@ -256,8 +256,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			SetPowershiftLossEnergy(absTime, dt, outTorque, outAngularVelocity);
 			do {
 				if (CurrentState.Disengaged 
-					|| DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted 
-					|| DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch) {
+					|| (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted)
+					|| (DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch)) {
 					// only when vehicle is halted or close before halting or during eco-roll events
 					retVal = RequestDisengaged(absTime, dt, outTorque, outAngularVelocity, dryRun);
 				} else {
-- 
GitLab