summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs5
-rw-r--r--src/System.Private.CoreLib/src/System/RtType.cs23
2 files changed, 10 insertions, 18 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs
index ea7387589c..61143fecfd 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs
@@ -1391,9 +1391,8 @@ namespace System
results.Add(strings[j]);
}
}
- string[] value = new string[results.Count];
- results.CopyTo(0, value, 0, results.Count);
- return (value);
+
+ return results.ToArray();
}
// This is a placeholder for an MDA to detect when the user is using a
diff --git a/src/System.Private.CoreLib/src/System/RtType.cs b/src/System.Private.CoreLib/src/System/RtType.cs
index 921c15e25b..e423b45718 100644
--- a/src/System.Private.CoreLib/src/System/RtType.cs
+++ b/src/System.Private.CoreLib/src/System/RtType.cs
@@ -4097,8 +4097,7 @@ namespace System
if (results != null)
{
Debug.Assert(results.Count > 1);
- finalists = new MethodInfo[results.Count];
- results.CopyTo(finalists);
+ finalists = results.ToArray();
}
}
@@ -4149,8 +4148,7 @@ namespace System
if (results != null)
{
Debug.Assert(results.Count > 1);
- finalists = new MethodInfo[results.Count];
- results.CopyTo(finalists);
+ finalists = results.ToArray();
}
}
@@ -4342,8 +4340,6 @@ namespace System
if (args == null)
args = Array.Empty<object>();
- int argCnt = args.Length;
-
// Without a binder we need to do use the default binder...
if (binder == null)
binder = DefaultBinder;
@@ -4352,7 +4348,7 @@ namespace System
// so a call to GetMemberCons would fail
bool publicOnly = (bindingAttr & BindingFlags.NonPublic) == 0;
bool wrapExceptions = (bindingAttr & BindingFlags.DoNotWrapExceptions) == 0;
- if (argCnt == 0 && (bindingAttr & BindingFlags.Public) != 0 && (bindingAttr & BindingFlags.Instance) != 0
+ if (args.Length == 0 && (bindingAttr & BindingFlags.Public) != 0 && (bindingAttr & BindingFlags.Instance) != 0
&& (IsGenericCOMObjectImpl() || IsValueType))
{
server = CreateInstanceDefaultCtor(publicOnly, false, true, wrapExceptions);
@@ -4363,8 +4359,8 @@ namespace System
List<MethodBase> matches = new List<MethodBase>(candidates.Length);
// We cannot use Type.GetTypeArray here because some of the args might be null
- Type[] argsType = new Type[argCnt];
- for (int i = 0; i < argCnt; i++)
+ Type[] argsType = new Type[args.Length];
+ for (int i = 0; i < args.Length; i++)
{
if (args[i] != null)
{
@@ -4378,16 +4374,13 @@ namespace System
matches.Add(candidates[i]);
}
- MethodBase[] cons = new MethodBase[matches.Count];
- matches.CopyTo(cons);
- if (cons != null && cons.Length == 0)
- cons = null;
-
- if (cons == null)
+ if (matches.Count == 0)
{
throw new MissingMethodException(SR.Format(SR.MissingConstructor_Name, FullName));
}
+ MethodBase[] cons = matches.ToArray();
+
MethodBase invokeMethod;
object state = null;