Skip to content

Commit 5bb9de3

Browse files
committed
TupleDescriptor: no repeated call of Count prop while for-looping
1 parent d066477 commit 5bb9de3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Orm/Xtensive.Orm/Tuples/TupleDescriptor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public int Count
5555
/// <inheritdoc/>
5656
public IEnumerator<Type> GetEnumerator()
5757
{
58-
for (var index = 0; index < Count; index++) {
58+
for (int index = 0, count = Count; index < count; index++) {
5959
yield return FieldTypes[index];
6060
}
6161
}
@@ -81,7 +81,7 @@ public bool Equals(TupleDescriptor other)
8181
return false;
8282
}
8383

84-
for (int i = 0; i < Count; i++) {
84+
for (int i = 0, count = Count; i < count; i++) {
8585
if (FieldTypes[i] != other.FieldTypes[i]) {
8686
return false;
8787
}
@@ -97,7 +97,7 @@ public override bool Equals(object obj) =>
9797
public override int GetHashCode()
9898
{
9999
int result = Count;
100-
for (int i = 0; i < Count; i++)
100+
for (int i = 0, count = Count; i < count; i++)
101101
result = unchecked (FieldTypes[i].GetHashCode() + 29 * result);
102102
return result;
103103
}
@@ -131,7 +131,7 @@ public void GetObjectData(SerializationInfo info, StreamingContext context)
131131
public override string ToString()
132132
{
133133
var sb = new ValueStringBuilder(stackalloc char[4096]);
134-
for (int i = 0; i < Count; i++) {
134+
for (int i = 0, count = Count; i < count; i++) {
135135
if (i > 0)
136136
sb.Append(", ");
137137
sb.Append(FieldTypes[i].GetShortName());

0 commit comments

Comments
 (0)