Skip to content

Commit f5a1b7e

Browse files
Potential fix for pull request finding 'Nested 'if' statements can be combined'
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
1 parent 5ff42a1 commit f5a1b7e

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/Foundatio/Utility/SizeCalculator.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,12 @@ private void EvictOldestEntries(ConcurrentDictionary<Type, TypeSizeCacheEntry> c
349349
foreach (var kvp in cache)
350350
{
351351
var lastAccess = Interlocked.Read(ref kvp.Value.LastAccessField);
352-
if (lastAccess < threshold)
352+
if (lastAccess < threshold && cache.TryRemove(kvp.Key, out _))
353353
{
354-
if (cache.TryRemove(kvp.Key, out _))
355-
{
356-
removed++;
357-
// Stop once we've removed enough
358-
if (removed >= toRemove)
359-
break;
360-
}
354+
removed++;
355+
// Stop once we've removed enough
356+
if (removed >= toRemove)
357+
break;
361358
}
362359
}
363360
}

0 commit comments

Comments
 (0)