summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Toub <stoub@microsoft.com>2019-01-21 21:56:55 -0500
committerGitHub <noreply@github.com>2019-01-21 21:56:55 -0500
commitedffbd9c545aa9c1f6cb7ae048efdf5db13d3991 (patch)
tree61e54096002f4f3624d46d2de1073d10f1eddf06
parent401e931714e9b0890aaaa047710d0eb582bb8722 (diff)
downloadcoreclr-edffbd9c545aa9c1f6cb7ae048efdf5db13d3991.tar.gz
coreclr-edffbd9c545aa9c1f6cb7ae048efdf5db13d3991.tar.bz2
coreclr-edffbd9c545aa9c1f6cb7ae048efdf5db13d3991.zip
Remove two unnecessary ToArray calls (#22119)
We can just copy directly from the List, rather than first converting the list to an array and then copying that.
-rw-r--r--src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs
index 94143f7005..bb8d2749fa 100644
--- a/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs
+++ b/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs
@@ -48,9 +48,9 @@ namespace System
AddAttributesToList(attributeList, attributes, types);
baseProp = GetParentDefinition(baseProp, indexParamTypes);
}
- Array array = CreateAttributeArrayHelper(type, attributeList.Count);
- Array.Copy(attributeList.ToArray(), 0, array, 0, attributeList.Count);
- return (Attribute[])array;
+ Attribute[] array = CreateAttributeArrayHelper(type, attributeList.Count);
+ attributeList.CopyTo(array, 0);
+ return array;
}
private static bool InternalIsDefined(PropertyInfo element, Type attributeType, bool inherit)
@@ -143,9 +143,9 @@ namespace System
AddAttributesToList(attributeList, attributes, types);
baseEvent = GetParentDefinition(baseEvent);
}
- Array array = CreateAttributeArrayHelper(type, attributeList.Count);
- Array.Copy(attributeList.ToArray(), 0, array, 0, attributeList.Count);
- return (Attribute[])array;
+ Attribute[] array = CreateAttributeArrayHelper(type, attributeList.Count);
+ attributeList.CopyTo(array, 0);
+ return array;
}
else
return attributes;