From 19bb166ed39606ec2d811ebdcb6530d09ec2c1db Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 8 Jul 2025 23:10:49 +0100 Subject: [PATCH] [Refactor] Use collection expression. --- RomRepoMgr.Core/Filesystem/Fuse.cs | 4 ++-- RomRepoMgr.Core/Filesystem/Vfs.cs | 8 ++++---- RomRepoMgr.Core/Workers/DatImporter.cs | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/RomRepoMgr.Core/Filesystem/Fuse.cs b/RomRepoMgr.Core/Filesystem/Fuse.cs index a8b5104..033a000 100644 --- a/RomRepoMgr.Core/Filesystem/Fuse.cs +++ b/RomRepoMgr.Core/Filesystem/Fuse.cs @@ -25,9 +25,9 @@ public sealed class Fuse : FileSystem public Fuse(Vfs vfs) { - _directoryCache = new ConcurrentDictionary>(); + _directoryCache = []; _lastHandle = 0; - _fileStatHandleCache = new ConcurrentDictionary(); + _fileStatHandleCache = []; Name = "romrepomgrfs"; _vfs = vfs; } diff --git a/RomRepoMgr.Core/Filesystem/Vfs.cs b/RomRepoMgr.Core/Filesystem/Vfs.cs index 9513e71..d3eae22 100644 --- a/RomRepoMgr.Core/Filesystem/Vfs.cs +++ b/RomRepoMgr.Core/Filesystem/Vfs.cs @@ -197,7 +197,7 @@ public class Vfs : IDisposable if(cachedMachines != null) return cachedMachines; - cachedMachines = new ConcurrentDictionary(); + cachedMachines = []; using var ctx = Context.Create(Settings.Settings.Current.DatabasePath); @@ -233,7 +233,7 @@ public class Vfs : IDisposable using var ctx = Context.Create(Settings.Settings.Current.DatabasePath); - cachedMachineFiles = new ConcurrentDictionary(); + cachedMachineFiles = []; foreach(FileByMachine machineFile in ctx.FilesByMachines.Where(fbm => fbm.Machine.Id == id && fbm.File.IsInRepo) .Include(fileByMachine => fileByMachine.File)) @@ -269,7 +269,7 @@ public class Vfs : IDisposable using var ctx = Context.Create(Settings.Settings.Current.DatabasePath); - cachedMachineDisks = new ConcurrentDictionary(); + cachedMachineDisks = []; foreach(DiskByMachine machineDisk in ctx.DisksByMachines .Where(dbm => dbm.Machine.Id == id && @@ -303,7 +303,7 @@ public class Vfs : IDisposable using var ctx = Context.Create(Settings.Settings.Current.DatabasePath); - cachedMachineMedias = new ConcurrentDictionary(); + cachedMachineMedias = []; foreach(MediaByMachine machineMedia in ctx.MediasByMachines .Where(mbm => mbm.Machine.Id == id && diff --git a/RomRepoMgr.Core/Workers/DatImporter.cs b/RomRepoMgr.Core/Workers/DatImporter.cs index be9d59b..2839570 100644 --- a/RomRepoMgr.Core/Workers/DatImporter.cs +++ b/RomRepoMgr.Core/Workers/DatImporter.cs @@ -514,35 +514,35 @@ public sealed class DatImporter ? ctx.Disks .FromSqlRaw($"SELECT DISTINCT f.* FROM Disks AS f, [{tmpDiskMd5Table}] AS t WHERE f.Md5 = t.Md5") .ToDictionary(f => f.Md5) - : new Dictionary(); + : []; Dictionary pendingDisksBySha1 = disksHaveSha1 ? ctx.Disks .FromSqlRaw($"SELECT DISTINCT f.* FROM Disks AS f, [{tmpDiskSha1Table}] AS t WHERE f.Sha1 = t.Sha1") .ToDictionary(f => f.Sha1) - : new Dictionary(); + : []; Dictionary pendingMediasByMd5 = mediasHaveMd5 ? ctx.Medias .FromSqlRaw($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaMd5Table}] AS t WHERE f.Md5 = t.Md5") .ToDictionary(f => f.Md5) - : new Dictionary(); + : []; Dictionary pendingMediasBySha1 = mediasHaveSha1 ? ctx.Medias .FromSqlRaw($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaSha1Table}] AS t WHERE f.Sha1 = t.Sha1") .ToDictionary(f => f.Sha1) - : new Dictionary(); + : []; Dictionary pendingMediasBySha256 = mediasHaveSha256 ? ctx.Medias .FromSqlRaw($"SELECT DISTINCT f.* FROM Medias AS f, [{tmpMediaSha256Table}] AS t WHERE f.Sha256 = t.Sha256") .ToDictionary(f => f.Sha256) - : new Dictionary(); + : []; var pendingFilesByCrc = new Dictionary(); var pendingFilesByMd5 = new Dictionary();