@@ -6,59 +6,27 @@ namespace HydraScript.Application.StaticAnalysis.Impl;
66
77internal class FunctionWithUndefinedReturnStorage : IFunctionWithUndefinedReturnStorage
88{
9- #if NET10_0
109 private readonly OrderedDictionary < FunctionSymbolId , FunctionDeclaration > _declarations = [ ] ;
11- #else
12- private readonly Dictionary < FunctionSymbolId , FunctionDeclaration > _declarations = [ ] ;
13- private readonly Dictionary < FunctionSymbolId , int > _keysWithOrder = [ ] ;
14- #endif
1510
16- public void Save ( FunctionSymbol symbol , FunctionDeclaration declaration )
17- {
18- _declarations [ symbol . Id ] = declaration ;
19- #if NET10_0
20- #else
21- _keysWithOrder [ symbol . Id ] = _declarations . Count ;
22- #endif
23- }
11+ public void Save ( FunctionSymbol symbol , FunctionDeclaration declaration ) => _declarations [ symbol . Id ] = declaration ;
2412
2513 public FunctionDeclaration Get ( FunctionSymbol symbol )
2614 {
2715 if ( ! _declarations . Remove ( symbol . Id , out var declaration ) )
2816 throw new InvalidOperationException ( message : $ "Cannot get { symbol } that has not been saved") ;
29- #if NET10_0
30- #else
31- _keysWithOrder . Remove ( symbol . Id ) ;
32- #endif
17+
3318 return declaration ;
3419 }
3520
36- public void RemoveIfPresent ( FunctionSymbol symbol )
37- {
38- _declarations . Remove ( symbol . Id ) ;
39- #if NET10_0
40- #else
41- _keysWithOrder . Remove ( symbol . Id ) ;
42- #endif
43- }
21+ public void RemoveIfPresent ( FunctionSymbol symbol ) => _declarations . Remove ( symbol . Id ) ;
4422
4523 public IEnumerable < FunctionDeclaration > Flush ( )
4624 {
47- #if NET10_0
4825 IReadOnlyList < FunctionSymbolId > keys = _declarations . Keys ;
4926 while ( keys . Count > 0 )
5027 {
5128 yield return _declarations [ keys [ 0 ] ] ;
5229 _declarations . Remove ( keys [ 0 ] ) ;
5330 }
54- #else
55- return _declarations . OrderBy ( kvp => _keysWithOrder [ kvp . Key ] )
56- . Select ( x =>
57- {
58- _declarations . Remove ( x . Key ) ;
59- _keysWithOrder . Remove ( x . Key ) ;
60- return x . Value ;
61- } ) ;
62- #endif
6331 }
6432}
0 commit comments