From 041dfab0c22daa81fe304d67283223b8bd923f52 Mon Sep 17 00:00:00 2001 From: Sam Pavlovic Date: Sun, 30 Nov 2025 13:30:41 -0300 Subject: [PATCH] Use a Dictionary instead of List for Mounting file entries, using their path as key (#3496) Games with multiple archives can have multiple files with same names through their archives, either for HDD/CD seek optimization with sequential access redundancy or patch versioning We don't even support duplicate file names in archive loading but they'd be added regardless to our list & UI --- .../Sandbox.Mounting/MountedGame/BaseGameMount.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/engine/Mounting/Sandbox.Mounting/MountedGame/BaseGameMount.cs b/engine/Mounting/Sandbox.Mounting/MountedGame/BaseGameMount.cs index 9db0b4a7..93eb1d11 100644 --- a/engine/Mounting/Sandbox.Mounting/MountedGame/BaseGameMount.cs +++ b/engine/Mounting/Sandbox.Mounting/MountedGame/BaseGameMount.cs @@ -63,7 +63,7 @@ public abstract class BaseGameMount await Mount( new MountContext( this ) ); - foreach ( var entry in _entries ) + foreach ( var entry in _entries.Values ) { RootFolder.AddResource( entry ); } @@ -81,7 +81,7 @@ public abstract class BaseGameMount Shutdown(); - foreach ( var entry in _entries ) + foreach ( var entry in _entries.Values ) { entry?.ShutdownInternal(); } @@ -98,19 +98,18 @@ public abstract class BaseGameMount } - readonly List _entries = []; + readonly Dictionary _entries = []; /// /// All of the resources in this game /// - public IReadOnlyCollection Resources => _entries.AsReadOnly(); + public IReadOnlyCollection Resources => _entries.Values; public ResourceFolder RootFolder { get; internal set; } internal void RegisterFileInternal( ResourceLoader entry ) { - _entries.Add( entry ); - + _entries[entry.Path] = entry; } ///