Skip to content

Commit 28c708a

Browse files
committed
avoid getting .Length/.Count property on each iteration
1 parent cc1628f commit 28c708a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Orm/Xtensive.Orm/Tuples/TupleExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ private static void CopyTupleWithMappingSlow(Tuple source, Tuple target, IReadOn
483483

484484
private static void CopyTupleWithMappingFast(PackedTuple source, PackedTuple target, IReadOnlyList<int> map)
485485
{
486-
for (int targetIndex = 0; targetIndex < map.Count; targetIndex++) {
486+
for (int targetIndex = 0, count = map.Count; targetIndex < count; targetIndex++) {
487487
var sourceIndex = map[targetIndex];
488488
if (sourceIndex >= 0)
489489
CopyPackedValue(source, sourceIndex, target, targetIndex);
@@ -503,7 +503,7 @@ private static void CopyTupleArrayWithMappingSlow(Tuple[] sources, Tuple target,
503503

504504
private static void CopyTupleArrayWithMappingFast(PackedTuple[] sources, PackedTuple target, Pair<int, int>[] map)
505505
{
506-
for (int targetIndex = 0; targetIndex < map.Length; targetIndex++) {
506+
for (int targetIndex = 0, length = map.Length; targetIndex < length; targetIndex++) {
507507
var sourceInfo = map[targetIndex];
508508
var sourceTupleIndex = sourceInfo.First;
509509
var sourceFieldIndex = sourceInfo.Second;
@@ -525,7 +525,7 @@ private static void Copy3TuplesWithMappingSlow(FixedList3<Tuple> sources, Tuple
525525

526526
private static void Copy3TuplesWithMappingFast(FixedList3<PackedTuple> sources, PackedTuple target, Pair<int, int>[] map)
527527
{
528-
for (int targetIndex = 0; targetIndex < map.Length; targetIndex++) {
528+
for (int targetIndex = 0, length = map.Length; targetIndex < length; targetIndex++) {
529529
var sourceInfo = map[targetIndex];
530530
var sourceTupleIndex = sourceInfo.First;
531531
var sourceFieldIndex = sourceInfo.Second;

0 commit comments

Comments
 (0)