@@ -4097,8 +4097,7 @@ public override object InvokeMember(
4097
4097
if ( results != null )
4098
4098
{
4099
4099
Debug . Assert ( results . Count > 1 ) ;
4100
- finalists = new MethodInfo [ results . Count ] ;
4101
- results . CopyTo ( finalists ) ;
4100
+ finalists = results . ToArray ( ) ;
4102
4101
}
4103
4102
}
4104
4103
@@ -4149,8 +4148,7 @@ public override object InvokeMember(
4149
4148
if ( results != null )
4150
4149
{
4151
4150
Debug . Assert ( results . Count > 1 ) ;
4152
- finalists = new MethodInfo [ results . Count ] ;
4153
- results . CopyTo ( finalists ) ;
4151
+ finalists = results . ToArray ( ) ;
4154
4152
}
4155
4153
}
4156
4154
@@ -4342,8 +4340,6 @@ internal object CreateInstanceImpl(
4342
4340
if ( args == null )
4343
4341
args = Array . Empty < object > ( ) ;
4344
4342
4345
- int argCnt = args . Length ;
4346
-
4347
4343
// Without a binder we need to do use the default binder...
4348
4344
if ( binder == null )
4349
4345
binder = DefaultBinder ;
@@ -4352,7 +4348,7 @@ internal object CreateInstanceImpl(
4352
4348
// so a call to GetMemberCons would fail
4353
4349
bool publicOnly = ( bindingAttr & BindingFlags . NonPublic ) == 0 ;
4354
4350
bool wrapExceptions = ( bindingAttr & BindingFlags . DoNotWrapExceptions ) == 0 ;
4355
- if ( argCnt == 0 && ( bindingAttr & BindingFlags . Public ) != 0 && ( bindingAttr & BindingFlags . Instance ) != 0
4351
+ if ( args . Length == 0 && ( bindingAttr & BindingFlags . Public ) != 0 && ( bindingAttr & BindingFlags . Instance ) != 0
4356
4352
&& ( IsGenericCOMObjectImpl ( ) || IsValueType ) )
4357
4353
{
4358
4354
server = CreateInstanceDefaultCtor ( publicOnly , false , true , wrapExceptions ) ;
@@ -4363,8 +4359,8 @@ internal object CreateInstanceImpl(
4363
4359
List < MethodBase > matches = new List < MethodBase > ( candidates . Length ) ;
4364
4360
4365
4361
// We cannot use Type.GetTypeArray here because some of the args might be null
4366
- Type [ ] argsType = new Type [ argCnt ] ;
4367
- for ( int i = 0 ; i < argCnt ; i ++ )
4362
+ Type [ ] argsType = new Type [ args . Length ] ;
4363
+ for ( int i = 0 ; i < args . Length ; i ++ )
4368
4364
{
4369
4365
if ( args [ i ] != null )
4370
4366
{
@@ -4378,16 +4374,13 @@ internal object CreateInstanceImpl(
4378
4374
matches . Add ( candidates [ i ] ) ;
4379
4375
}
4380
4376
4381
- MethodBase [ ] cons = new MethodBase [ matches . Count ] ;
4382
- matches . CopyTo ( cons ) ;
4383
- if ( cons != null && cons . Length == 0 )
4384
- cons = null ;
4385
-
4386
- if ( cons == null )
4377
+ if ( matches . Count == 0 )
4387
4378
{
4388
4379
throw new MissingMethodException ( SR . Format ( SR . MissingConstructor_Name , FullName ) ) ;
4389
4380
}
4390
4381
4382
+ MethodBase [ ] cons = matches . ToArray ( ) ;
4383
+
4391
4384
MethodBase invokeMethod ;
4392
4385
object state = null ;
4393
4386
0 commit comments