Skip to content

Commit 883b84b

Browse files
committed
MemoryGroup code cleanup
1 parent fcef71a commit 883b84b

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

OpenHardwareMonitorLib/Hardware/Memory/MemoryGroup.cs

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,15 @@ private bool TryAddDimms(ISettings settings)
9191
lock (_lock)
9292
{
9393
if (_disposed)
94-
{
9594
return false;
96-
}
97-
98-
if (DetectThermalSensors(out List<SPDAccessor> accessors))
99-
{
100-
AddDimms(accessors, settings);
101-
return true;
102-
}
95+
return AddDimms(settings);
10396
}
10497
}
10598
catch (Exception ex)
10699
{
107100
_lastException = ex;
108101
Debug.Assert(false, "Exception while detecting RAM: " + ex.Message);
109102
}
110-
111103
return false;
112104
}
113105

@@ -126,41 +118,25 @@ private void StartRetryTask(ISettings settings)
126118
}, _cancellationTokenSource.Token);
127119
}
128120

129-
private static bool DetectThermalSensors(out List<SPDAccessor> accessors)
121+
private bool AddDimms(ISettings settings)
130122
{
131-
accessors = [];
132-
123+
List<SPDAccessor> accessors = [];
133124
bool ramDetected = false;
134-
135125
SMBusManager.DetectSMBuses();
136-
137-
//Go through detected SMBuses
138126
foreach (SMBusInterface smbus in SMBusManager.RegisteredSMBuses)
139127
{
140-
//Go through possible RAM slots
141128
for (byte i = SPDConstants.SPD_BEGIN; i <= SPDConstants.SPD_END; ++i)
142129
{
143-
//Detect type of RAM, if available
144130
SPDDetector detector = new(smbus, i);
145-
146-
//RAM available and detected
147131
if (detector.Accessor != null)
148132
{
149-
//Add all detected modules
150133
accessors.Add(detector.Accessor);
151-
152134
ramDetected = true;
153135
}
154136
}
155137
}
156138

157-
return ramDetected;
158-
}
159-
160-
private void AddDimms(List<SPDAccessor> accessors, ISettings settings)
161-
{
162139
List<Hardware> additions = [];
163-
164140
foreach (SPDAccessor ram in accessors)
165141
{
166142
//Default value
@@ -177,5 +153,7 @@ private void AddDimms(List<SPDAccessor> accessors, ISettings settings)
177153
_hardware = [.. _hardware, .. additions];
178154
foreach (Hardware hardware in additions)
179155
HardwareAdded?.Invoke(hardware);
156+
157+
return ramDetected;
180158
}
181159
}

0 commit comments

Comments
 (0)