Skip to content

Commit 0dc368d

Browse files
committed
A couple minor improvements on code style
1 parent d37ff7a commit 0dc368d

File tree

3 files changed

+12
-38
lines changed

3 files changed

+12
-38
lines changed

src/LightningDB/DatabaseConfiguration.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,18 @@ internal IDisposable ConfigureDatabase(LightningTransaction tx, LightningDatabas
3737
var pinnedComparer = new ComparerKeepAlive();
3838
if (_comparer != null)
3939
{
40-
CompareFunction compare = Compare;
40+
CompareFunction compare = (ref left, ref right) => _comparer.Compare(left, right);
4141
pinnedComparer.AddComparer(compare);
4242
mdb_set_compare(tx._handle, db._handle, compare);
4343
}
4444

4545
if (_duplicatesComparer == null) return pinnedComparer;
46-
CompareFunction dupCompare = IsDuplicate;
46+
CompareFunction dupCompare = (ref left, ref right) => _duplicatesComparer.Compare(left, right);
4747
pinnedComparer.AddComparer(dupCompare);
4848
mdb_set_dupsort(tx._handle, db._handle, dupCompare);
4949
return pinnedComparer;
5050
}
5151

52-
private int Compare(ref MDBValue left, ref MDBValue right)
53-
{
54-
return _comparer.Compare(left, right);
55-
}
56-
57-
private int IsDuplicate(ref MDBValue left, ref MDBValue right)
58-
{
59-
return _duplicatesComparer.Compare(left, right);
60-
}
61-
6252
/// <summary>
6353
/// Sets a custom comparer for database operations using the specified comparer.
6454
/// </summary>

src/LightningDB/EnvironmentConfiguration.cs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
/// </remarks>
1111
public class EnvironmentConfiguration
1212
{
13-
private long? _mapSize;
14-
private int? _maxReaders;
15-
private int? _maxDatabases;
16-
1713
/// <summary>
1814
/// Gets or sets the size of the memory map (in bytes) for a LightningEnvironment.
1915
/// </summary>
@@ -27,11 +23,7 @@ public class EnvironmentConfiguration
2723
/// Use caution when setting this value in applications running in 32-bit processes, as the effective addressable memory
2824
/// space is limited. For such scenarios, auto-adjustments may be applied to ensure compatibility.
2925
/// </remarks>
30-
public long MapSize
31-
{
32-
get => _mapSize ?? 0;
33-
set => _mapSize = value;
34-
}
26+
public long MapSize { get; set; }
3527

3628
/// <summary>
3729
/// Gets or sets the maximum number of reader slots available for a LightningEnvironment instance.
@@ -44,11 +36,7 @@ public long MapSize
4436
/// property after the environment is already initialized will result in an exception. Adjust this parameter to match
4537
/// the requirements of your application's workload and concurrency needs.
4638
/// </remarks>
47-
public int MaxReaders
48-
{
49-
get => _maxReaders ?? 0;
50-
set => _maxReaders = value;
51-
}
39+
public int MaxReaders { get; set; }
5240

5341
/// <summary>
5442
/// Gets or sets the maximum number of databases that can be opened within a LightningEnvironment instance.
@@ -63,11 +51,7 @@ public int MaxReaders
6351
/// Configuring the appropriate <c>MaxDatabases</c> value is particularly relevant for applications requiring concurrency or
6452
/// multiple named databases.
6553
/// </remarks>
66-
public int MaxDatabases
67-
{
68-
get => _maxDatabases ?? 0;
69-
set => _maxDatabases = value;
70-
}
54+
public int MaxDatabases { get; set; }
7155

7256
/// <summary>
7357
/// Gets or sets a value indicating whether the map size should be automatically reduced
@@ -86,13 +70,13 @@ public int MaxDatabases
8670

8771
internal void Configure(LightningEnvironment env)
8872
{
89-
if (_mapSize.HasValue)
90-
env.MapSize = _mapSize.Value;
73+
if (MapSize > 0)
74+
env.MapSize = MapSize;
9175

92-
if (_maxDatabases.HasValue)
93-
env.MaxDatabases = _maxDatabases.Value;
76+
if (MaxDatabases > 0)
77+
env.MaxDatabases = MaxDatabases;
9478

95-
if (_maxReaders.HasValue)
96-
env.MaxReaders = _maxReaders.Value;
79+
if (MaxReaders > 0)
80+
env.MaxReaders = MaxReaders;
9781
}
9882
}

src/LightningDB/LightningDB.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<VersionPrefix>0.20.0</VersionPrefix>
66
<Authors>Ilya Lukyanov;Corey Kaylor</Authors>
77
<TargetFrameworks>netstandard2.0;net8.0;net9.0;net10.0</TargetFrameworks>
8-
<LangVersion>13</LangVersion>
8+
<LangVersion>14</LangVersion>
99
<AssemblyName>LightningDB</AssemblyName>
1010
<PackageId>LightningDB</PackageId>
1111
<PackageIcon>lightningdb.png</PackageIcon>

0 commit comments

Comments
 (0)