Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormikedn <onemihaid@hotmail.com>2017-01-15 18:05:48 +0300
committerJan Kotas <jkotas@microsoft.com>2017-01-15 18:05:48 +0300
commit63cc02771ecd502794340b826671b4f90d214b0f (patch)
tree6d78e0f19a812025d4ed9979acfe1739908bcef1
parent896ed6bd6a01b5bd02394d4f905b679ae6acafcb (diff)
Prefer using Array.Length as upper for loop limit (#2513)
Port of https://github.com/dotnet/coreclr/pull/8923
-rw-r--r--src/System.Private.CoreLib/src/System/Delegate.cs2
-rw-r--r--src/System.Private.CoreLib/src/System/Reflection/Assembly.cs7
-rw-r--r--src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs2
3 files changed, 5 insertions, 6 deletions
diff --git a/src/System.Private.CoreLib/src/System/Delegate.cs b/src/System.Private.CoreLib/src/System/Delegate.cs
index 399fd783b..8263a8ac6 100644
--- a/src/System.Private.CoreLib/src/System/Delegate.cs
+++ b/src/System.Private.CoreLib/src/System/Delegate.cs
@@ -630,7 +630,7 @@ namespace System
int invocationCount = (int)m_extraFunctionPointerOrData;
del = new Delegate[invocationCount];
- for (int i = 0; i < invocationCount; i++)
+ for (int i = 0; i < del.Length; i++)
del[i] = invocationList[i];
}
return del;
diff --git a/src/System.Private.CoreLib/src/System/Reflection/Assembly.cs b/src/System.Private.CoreLib/src/System/Reflection/Assembly.cs
index 2405a050f..66f68e474 100644
--- a/src/System.Private.CoreLib/src/System/Reflection/Assembly.cs
+++ b/src/System.Private.CoreLib/src/System/Reflection/Assembly.cs
@@ -38,11 +38,10 @@ namespace System.Reflection
{
Module[] m = GetModules(false);
- int numModules = m.Length;
int finalLength = 0;
- Type[][] moduleTypes = new Type[numModules][];
+ Type[][] moduleTypes = new Type[m.Length][];
- for (int i = 0; i < numModules; i++)
+ for (int i = 0; i < moduleTypes.Length; i++)
{
moduleTypes[i] = m[i].GetTypes();
finalLength += moduleTypes[i].Length;
@@ -50,7 +49,7 @@ namespace System.Reflection
int current = 0;
Type[] ret = new Type[finalLength];
- for (int i = 0; i < numModules; i++)
+ for (int i = 0; i < moduleTypes.Length; i++)
{
int length = moduleTypes[i].Length;
Array.Copy(moduleTypes[i], 0, ret, current, length);
diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
index b5caeb690..5bf209549 100644
--- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
+++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
@@ -528,7 +528,7 @@ namespace System.Runtime.CompilerServices
// Reallocate both buckets and entries and rebuild the bucket and entries from scratch.
// This serves both to scrub entries with expired keys and to put the new entries in the proper bucket.
int[] newBuckets = new int[newSize];
- for (int bucketIndex = 0; bucketIndex < newSize; bucketIndex++)
+ for (int bucketIndex = 0; bucketIndex < newBuckets.Length; bucketIndex++)
{
newBuckets[bucketIndex] = -1;
}