@@ -225,44 +225,38 @@ bool TryUnbundle(ReadOnlySpan<char> alias, int argumentIndex)
225
225
{
226
226
int tokensBefore = tokenList . Count ;
227
227
228
- string candidate = new ( '-' , 2 ) ; // mutable string used to avoid allocations
229
- unsafe
228
+ Span < char > candidate = [ '-' , '-' ] ;
229
+ for ( int i = 0 ; i < alias . Length ; i ++ )
230
230
{
231
- fixed ( char * pCandidate = candidate )
231
+ if ( alias [ i ] == ':' || alias [ i ] == '=' )
232
232
{
233
- for ( int i = 0 ; i < alias . Length ; i ++ )
234
- {
235
- if ( alias [ i ] == ':' || alias [ i ] == '=' )
236
- {
237
- tokenList . Add ( new Token ( alias . Slice ( i + 1 ) . ToString ( ) , TokenType . Argument , default , argumentIndex ) ) ;
238
- return true ;
239
- }
233
+ tokenList . Add ( new Token ( alias . Slice ( i + 1 ) . ToString ( ) , TokenType . Argument , default , argumentIndex ) ) ;
234
+ return true ;
235
+ }
240
236
241
- pCandidate [ 1 ] = alias [ i ] ;
242
- if ( ! knownTokens . TryGetValue ( candidate , out Token ? found ) )
243
- {
244
- if ( tokensBefore != tokenList . Count && tokenList [ tokenList . Count - 1 ] . Type == TokenType . Option )
245
- {
246
- // Invalid_char_in_bundle_causes_rest_to_be_interpreted_as_value
247
- tokenList . Add ( new Token ( alias . Slice ( i ) . ToString ( ) , TokenType . Argument , default , argumentIndex ) ) ;
248
- return true ;
249
- }
237
+ candidate [ 1 ] = alias [ i ] ;
238
+ if ( ! knownTokens . TryGetValue ( candidate . ToString ( ) , out Token ? found ) )
239
+ {
240
+ if ( tokensBefore != tokenList . Count && tokenList [ tokenList . Count - 1 ] . Type == TokenType . Option )
241
+ {
242
+ // Invalid_char_in_bundle_causes_rest_to_be_interpreted_as_value
243
+ tokenList . Add ( new Token ( alias . Slice ( i ) . ToString ( ) , TokenType . Argument , default , argumentIndex ) ) ;
244
+ return true ;
245
+ }
250
246
251
- return false ;
252
- }
247
+ return false ;
248
+ }
253
249
254
- tokenList . Add ( new Token ( found . Value , found . Type , found . Symbol , argumentIndex ) ) ;
255
- if ( i != alias . Length - 1 && ( ( Option ) found . Symbol ! ) . Greedy )
256
- {
257
- int index = i + 1 ;
258
- if ( alias [ index ] == ':' || alias [ index ] == '=' )
259
- {
260
- index ++ ; // Last_bundled_option_can_accept_argument_with_colon_separator
261
- }
262
- tokenList . Add ( new Token ( alias . Slice ( index ) . ToString ( ) , TokenType . Argument , default , argumentIndex ) ) ;
263
- return true ;
264
- }
250
+ tokenList . Add ( new Token ( found . Value , found . Type , found . Symbol , argumentIndex ) ) ;
251
+ if ( i != alias . Length - 1 && ( ( Option ) found . Symbol ! ) . Greedy )
252
+ {
253
+ int index = i + 1 ;
254
+ if ( alias [ index ] == ':' || alias [ index ] == '=' )
255
+ {
256
+ index ++ ; // Last_bundled_option_can_accept_argument_with_colon_separator
265
257
}
258
+ tokenList . Add ( new Token ( alias . Slice ( index ) . ToString ( ) , TokenType . Argument , default , argumentIndex ) ) ;
259
+ return true ;
266
260
}
267
261
}
268
262
0 commit comments