Minor performance tweaks
This commit is contained in:
@@ -73,7 +73,7 @@ public sealed partial class SimulatorWindow : Window, IDisposable
|
|||||||
|
|
||||||
SolverInitialActionCount = Actions.Count;
|
SolverInitialActionCount = Actions.Count;
|
||||||
SolverTaskToken = new();
|
SolverTaskToken = new();
|
||||||
Func<SolverConfig, SimulationState, Action<ActionType>?, CancellationToken, (List<ActionType> Actions, SimulationState State)> solverMethod = Configuration.SolverAlgorithm switch
|
Func<SolverConfig, SimulationState, Action<ActionType>?, CancellationToken, SolverSolution> solverMethod = Configuration.SolverAlgorithm switch
|
||||||
{
|
{
|
||||||
SolverAlgorithm.Oneshot => Solver.Crafty.Solver.SearchOneshot,
|
SolverAlgorithm.Oneshot => Solver.Crafty.Solver.SearchOneshot,
|
||||||
SolverAlgorithm.OneshotForked => Solver.Crafty.Solver.SearchOneshotForked,
|
SolverAlgorithm.OneshotForked => Solver.Crafty.Solver.SearchOneshotForked,
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public struct Effects
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public readonly byte GetStrength(EffectType effect) =>
|
public readonly byte GetStrength(EffectType effect) =>
|
||||||
effect == EffectType.InnerQuiet ? InnerQuiet :
|
effect == EffectType.InnerQuiet ? InnerQuiet :
|
||||||
(byte)(GetDuration(effect) != 0 ? 1 : 0);
|
(byte)(HasEffect(effect) ? 1 : 0);
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Craftimizer.Simulator.Actions;
|
using Craftimizer.Simulator.Actions;
|
||||||
|
using System.Diagnostics.Contracts;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace Craftimizer.Simulator;
|
namespace Craftimizer.Simulator;
|
||||||
|
|
||||||
@@ -62,6 +64,7 @@ public class Simulator
|
|||||||
return ActionResponse.UsedAction;
|
return ActionResponse.UsedAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void ExecuteForced(ActionType action, BaseAction baseAction)
|
public void ExecuteForced(ActionType action, BaseAction baseAction)
|
||||||
{
|
{
|
||||||
baseAction.Use(this);
|
baseAction.Use(this);
|
||||||
@@ -71,9 +74,13 @@ public class Simulator
|
|||||||
ActiveEffects.DecrementDuration();
|
ActiveEffects.DecrementDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Pure]
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int GetEffectStrength(EffectType effect) =>
|
public int GetEffectStrength(EffectType effect) =>
|
||||||
ActiveEffects.GetStrength(effect);
|
ActiveEffects.GetStrength(effect);
|
||||||
|
|
||||||
|
[Pure]
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int GetEffectDuration(EffectType effect) =>
|
public int GetEffectDuration(EffectType effect) =>
|
||||||
ActiveEffects.GetDuration(effect);
|
ActiveEffects.GetDuration(effect);
|
||||||
|
|
||||||
@@ -88,12 +95,16 @@ public class Simulator
|
|||||||
ActiveEffects.SetDuration(effect, (byte)duration);
|
ActiveEffects.SetDuration(effect, (byte)duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void StrengthenEffect(EffectType effect) =>
|
public void StrengthenEffect(EffectType effect) =>
|
||||||
ActiveEffects.Strengthen(effect);
|
ActiveEffects.Strengthen(effect);
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void RemoveEffect(EffectType effect) =>
|
public void RemoveEffect(EffectType effect) =>
|
||||||
ActiveEffects.SetDuration(effect, 0);
|
ActiveEffects.SetDuration(effect, 0);
|
||||||
|
|
||||||
|
[Pure]
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool HasEffect(EffectType effect) =>
|
public bool HasEffect(EffectType effect) =>
|
||||||
ActiveEffects.HasEffect(effect);
|
ActiveEffects.HasEffect(effect);
|
||||||
|
|
||||||
@@ -235,9 +246,11 @@ public class Simulator
|
|||||||
return qualityGain;
|
return qualityGain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void ReduceDurabilityRaw(int amount) =>
|
public void ReduceDurabilityRaw(int amount) =>
|
||||||
Durability -= amount;
|
Durability -= amount;
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void ReduceCPRaw(int amount) =>
|
public void ReduceCPRaw(int amount) =>
|
||||||
CP -= amount;
|
CP -= amount;
|
||||||
|
|
||||||
@@ -260,15 +273,19 @@ public class Simulator
|
|||||||
StrengthenEffect(EffectType.InnerQuiet);
|
StrengthenEffect(EffectType.InnerQuiet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void ReduceDurability(int amount) =>
|
public void ReduceDurability(int amount) =>
|
||||||
ReduceDurabilityRaw(CalculateDurabilityCost(amount));
|
ReduceDurabilityRaw(CalculateDurabilityCost(amount));
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void ReduceCP(int amount) =>
|
public void ReduceCP(int amount) =>
|
||||||
ReduceCPRaw(CalculateCPCost(amount));
|
ReduceCPRaw(CalculateCPCost(amount));
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void IncreaseProgress(float efficiency) =>
|
public void IncreaseProgress(float efficiency) =>
|
||||||
IncreaseProgressRaw(CalculateProgressGain(efficiency, false));
|
IncreaseProgressRaw(CalculateProgressGain(efficiency, false));
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void IncreaseQuality(float efficiency) =>
|
public void IncreaseQuality(float efficiency) =>
|
||||||
IncreaseQualityRaw(CalculateQualityGain(efficiency, false));
|
IncreaseQualityRaw(CalculateQualityGain(efficiency, false));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user