@@ -9,16 +9,16 @@ namespace Logic.Domain.Level5.Script.Xq32
9
9
internal class Xq32ScriptReader : ScriptReader < Xq32Function , Xq32Jump , Xq32Instruction , Xq32Argument > , IXq32ScriptReader
10
10
{
11
11
private readonly IBinaryFactory _binaryFactory ;
12
- private readonly Dictionary < uint , IList < string > > _functionCache ;
13
- private readonly Dictionary < uint , IList < string > > _jumpCache ;
12
+ private readonly Dictionary < uint , HashSet < string > > _functionCache ;
13
+ private readonly Dictionary < uint , HashSet < string > > _jumpCache ;
14
14
15
15
public Xq32ScriptReader ( IXq32ScriptDecompressor decompressor , IXq32ScriptEntrySizeProvider entrySizeProvider ,
16
16
IBinaryFactory binaryFactory )
17
17
: base ( decompressor , entrySizeProvider , binaryFactory )
18
18
{
19
19
_binaryFactory = binaryFactory ;
20
- _functionCache = new Dictionary < uint , IList < string > > ( ) ;
21
- _jumpCache = new Dictionary < uint , IList < string > > ( ) ;
20
+ _functionCache = new Dictionary < uint , HashSet < string > > ( ) ;
21
+ _jumpCache = new Dictionary < uint , HashSet < string > > ( ) ;
22
22
}
23
23
24
24
public override IReadOnlyList < Xq32Function > ReadFunctions ( Stream functionStream , int entryCount , PointerLength length )
@@ -185,8 +185,8 @@ protected override ScriptFunction CreateFunction(Xq32Function function, IBinaryR
185
185
stringReader . BaseStream . Position = function . nameOffset ;
186
186
name = stringReader . ReadCStringSJIS ( ) ;
187
187
188
- if ( ! _functionCache . TryGetValue ( function . crc32 , out IList < string > ? functionNames ) )
189
- _functionCache [ function . crc32 ] = functionNames = new List < string > ( ) ;
188
+ if ( ! _functionCache . TryGetValue ( function . crc32 , out HashSet < string > ? functionNames ) )
189
+ _functionCache [ function . crc32 ] = functionNames = new HashSet < string > ( ) ;
190
190
191
191
functionNames . Add ( name ) ;
192
192
}
@@ -216,8 +216,8 @@ protected override ScriptJump CreateJump(Xq32Jump jump, IBinaryReaderX? stringRe
216
216
stringReader . BaseStream . Position = jump . nameOffset ;
217
217
name = stringReader . ReadCStringSJIS ( ) ;
218
218
219
- if ( ! _jumpCache . TryGetValue ( jump . crc32 , out IList < string > ? jumpNames ) )
220
- _jumpCache [ jump . crc32 ] = jumpNames = new List < string > ( ) ;
219
+ if ( ! _jumpCache . TryGetValue ( jump . crc32 , out HashSet < string > ? jumpNames ) )
220
+ _jumpCache [ jump . crc32 ] = jumpNames = new HashSet < string > ( ) ;
221
221
222
222
jumpNames . Add ( name ) ;
223
223
}
@@ -262,7 +262,7 @@ protected override ScriptArgument CreateArgument(Xq32Argument argument, int inst
262
262
263
263
if ( argumentIndex != 0 )
264
264
{
265
- if ( _functionCache . TryGetValue ( ( ushort ) argument . value , out IList < string > ? names )
265
+ if ( _functionCache . TryGetValue ( ( ushort ) argument . value , out HashSet < string > ? names )
266
266
|| _jumpCache . TryGetValue ( ( ushort ) argument . value , out names ) )
267
267
value = names . First ( ) ;
268
268
break ;
@@ -271,22 +271,22 @@ protected override ScriptArgument CreateArgument(Xq32Argument argument, int inst
271
271
switch ( instructionType )
272
272
{
273
273
case 20 :
274
- if ( _functionCache . TryGetValue ( ( ushort ) argument . value , out IList < string > ? names ) )
274
+ if ( _functionCache . TryGetValue ( argument . value , out HashSet < string > ? names ) )
275
275
value = names . First ( ) ;
276
276
break ;
277
277
278
278
case 30 :
279
- if ( _jumpCache . TryGetValue ( ( ushort ) argument . value , out names ) )
279
+ if ( _jumpCache . TryGetValue ( argument . value , out names ) )
280
280
value = names . First ( ) ;
281
281
break ;
282
282
283
283
case 31 :
284
- if ( _jumpCache . TryGetValue ( ( ushort ) argument . value , out names ) )
284
+ if ( _jumpCache . TryGetValue ( argument . value , out names ) )
285
285
value = names . First ( ) ;
286
286
break ;
287
287
288
288
case 33 :
289
- if ( _jumpCache . TryGetValue ( ( ushort ) argument . value , out names ) )
289
+ if ( _jumpCache . TryGetValue ( argument . value , out names ) )
290
290
value = names . First ( ) ;
291
291
break ;
292
292
}
0 commit comments