11using System ;
2+ using System . Collections . Generic ;
23using System . Configuration ;
34using WowPacketParser . Enums ;
45using WowPacketParser . Misc ;
@@ -10,33 +11,33 @@ public class HotfixSettings
1011 public static HotfixSettings Instance { get ; } = new HotfixSettings ( ) ;
1112
1213 private HotfixSection Section => ( HotfixSection ) ConfigurationManager . GetSection ( "Hotfix" ) ;
13- private HotfixElementCollection Hashes => Section . FileHashes ;
14+ private IReadOnlySet < string > _hashes ;
15+
16+ public void LoadHashes ( )
17+ {
18+ var enabledTables = new HashSet < string > ( ) ;
19+
20+ foreach ( HotfixElement sectionFileHash in Section . FileHashes )
21+ if ( sectionFileHash . Enabled )
22+ enabledTables . Add ( sectionFileHash . FileHash ) ;
23+
24+ _hashes = enabledTables ;
25+ }
1426
1527 public bool ShouldLog ( DB2Hash fileHash )
1628 {
17- for ( var i = 0 ; i < Hashes . Count ; ++ i )
18- {
19- if ( Settings . ParseAllHotfixes == true )
20- return true ;
21-
22- var currentElement = Hashes [ i ] ;
23- if ( currentElement . FileHash == fileHash . ToString ( ) )
24- return currentElement . Enabled ;
25- }
26- return false ;
29+ if ( Settings . ParseAllHotfixes )
30+ return true ;
31+
32+ return _hashes . Contains ( fileHash . ToString ( ) ) ;
2733 }
2834
2935 public bool ShouldLog ( )
3036 {
31- for ( var i = 0 ; i < Hashes . Count ; ++ i )
32- {
33- if ( Settings . ParseAllHotfixes == true )
34- return true ;
35-
36- if ( Hashes [ i ] . Enabled )
37- return true ;
38- }
39- return false ;
37+ if ( Settings . ParseAllHotfixes )
38+ return true ;
39+
40+ return _hashes . Count > 0 ;
4041 }
4142 }
4243
0 commit comments