From 4c567150e09e1d9314c0a40b7a38647df432a95a Mon Sep 17 00:00:00 2001
From: Joyless <65855333+Joy-less@users.noreply.github.com>
Date: Wed, 5 Feb 2025 17:22:49 +0000
Subject: [PATCH 1/2] Use auto-implemented properties
---
BitFaster.Caching/Lru/EqualCapacityPartition.cs | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/BitFaster.Caching/Lru/EqualCapacityPartition.cs b/BitFaster.Caching/Lru/EqualCapacityPartition.cs
index a193efba..f2c5fcf7 100644
--- a/BitFaster.Caching/Lru/EqualCapacityPartition.cs
+++ b/BitFaster.Caching/Lru/EqualCapacityPartition.cs
@@ -9,10 +9,6 @@ namespace BitFaster.Caching.Lru
[DebuggerDisplay("{Hot}/{Warm}/{Cold}")]
public class EqualCapacityPartition : ICapacityPartition
{
- private readonly int hotCapacity;
- private readonly int warmCapacity;
- private readonly int coldCapacity;
-
///
/// Initializes a new instance of the EqualCapacityPartition class with the specified total capacity.
///
@@ -20,19 +16,19 @@ public class EqualCapacityPartition : ICapacityPartition
public EqualCapacityPartition(int totalCapacity)
{
var (hot, warm, cold) = ComputeQueueCapacity(totalCapacity);
- this.hotCapacity = hot;
- this.warmCapacity = warm;
- this.coldCapacity = cold;
+ this.Hot = hot;
+ this.Warm = warm;
+ this.Cold = cold;
}
///
- public int Cold => this.coldCapacity;
+ public int Cold { get; }
///
- public int Warm => this.warmCapacity;
+ public int Warm { get; }
///
- public int Hot => this.hotCapacity;
+ public int Hot { get; }
private static (int hot, int warm, int cold) ComputeQueueCapacity(int capacity)
{
From 70c9f0ec9c93b999bfce1bcd071318042c6718c9 Mon Sep 17 00:00:00 2001
From: Joyless <65855333+Joy-less@users.noreply.github.com>
Date: Thu, 6 Feb 2025 21:11:33 +0000
Subject: [PATCH 2/2] Further simplify
---
BitFaster.Caching/Lru/EqualCapacityPartition.cs | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/BitFaster.Caching/Lru/EqualCapacityPartition.cs b/BitFaster.Caching/Lru/EqualCapacityPartition.cs
index f2c5fcf7..9808283d 100644
--- a/BitFaster.Caching/Lru/EqualCapacityPartition.cs
+++ b/BitFaster.Caching/Lru/EqualCapacityPartition.cs
@@ -15,10 +15,7 @@ public class EqualCapacityPartition : ICapacityPartition
/// The total capacity.
public EqualCapacityPartition(int totalCapacity)
{
- var (hot, warm, cold) = ComputeQueueCapacity(totalCapacity);
- this.Hot = hot;
- this.Warm = warm;
- this.Cold = cold;
+ (Hot, Warm, Cold) = ComputeQueueCapacity(totalCapacity);
}
///