@@ -90,17 +90,13 @@ public bool ShouldDo(string name, Dictionary<string, TagExpectedValue>? expected
9090 }
9191
9292 public record ParsedHero {
93- public required Dictionary < string , ParsedArg > Types ;
93+ public readonly IgnoreCaseDict < ParsedArg > Types = [ ] ;
9494 public bool Matched = false ;
9595 }
9696
9797 public class ParsedNameSet {
98- private readonly IgnoreCaseDict < ParsedName > Map ;
98+ private readonly IgnoreCaseDict < ParsedName > Map = [ ] ;
9999 public int Count => Map . Count ;
100-
101- public ParsedNameSet ( ) {
102- Map = new IgnoreCaseDict < ParsedName > ( ) ;
103- }
104100
105101 public void Add ( ReadOnlySpan < char > value ) {
106102 Add ( value . ToString ( ) ) ;
@@ -309,7 +305,7 @@ protected virtual void QueryHelp(List<QueryType> types) {
309305 }
310306 }
311307
312- protected Dictionary < string , ParsedHero > ? ParseQuery (
308+ protected IgnoreCaseDict < ParsedHero > ? ParseQuery (
313309 ICLIFlags flags ,
314310 List < QueryType > queryTypes ,
315311 IgnoreCaseDict < string > ? queryNameOverrides = null ,
@@ -335,7 +331,7 @@ protected virtual void QueryHelp(List<QueryType> types) {
335331 var inputArguments = flags . Positionals . AsSpan ( 3 ) ;
336332 if ( inputArguments . Length == 0 ) return null ;
337333
338- Dictionary < string , ParsedHero > output = new IgnoreCaseDict < ParsedHero > ( ) ;
334+ var output = new IgnoreCaseDict < ParsedHero > ( ) ;
339335
340336 foreach ( string opt in inputArguments ) {
341337 if ( opt . StartsWith ( "--" ) ) continue ; // ok so this is a flag
@@ -351,10 +347,10 @@ protected virtual void QueryHelp(List<QueryType> types) {
351347 hero = nameForThisLocale ;
352348 }
353349
354- var heroOutput = new IgnoreCaseDict < ParsedArg > ( ) ;
355- output [ hero ] = new ParsedHero {
356- Types = heroOutput
357- } ;
350+ if ( ! output . TryGetValue ( hero , out var parsedHero ) ) {
351+ parsedHero = new ParsedHero ( ) ;
352+ output . Add ( hero , parsedHero ) ;
353+ }
358354
359355 var afterHero = split . AsSpan ( 1 ) ;
360356 if ( afterHero . Length == 0 ) {
@@ -365,7 +361,7 @@ protected virtual void QueryHelp(List<QueryType> types) {
365361 var parsedArg = new ParsedArg ( type ) ;
366362 PopulateDefaultTags ( type , parsedArg ) ;
367363
368- heroOutput . Add ( type . Name , parsedArg ) ;
364+ parsedHero . Types . Add ( type . Name , parsedArg ) ;
369365 }
370366 continue ;
371367 }
@@ -388,7 +384,7 @@ protected virtual void QueryHelp(List<QueryType> types) {
388384
389385 foreach ( QueryType queryType in typesMatchingName ) {
390386 var parsedArg = new ParsedArg ( queryType ) ;
391- heroOutput . Add ( queryType . Name , parsedArg ) ;
387+ parsedHero . Types . Add ( queryType . Name , parsedArg ) ;
392388 // todo: using .Add here can of course fail but we would previously only use the 2nd occurrence.. its better to explode
393389
394390 // todo: rewrite this parse loop...
0 commit comments