Skip to content

Commit 74909d0

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

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Orm/Xtensive.Orm/Tuples/TupleExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2008-2020 Xtensive LLC.
1+
// Copyright (C) 2008-2022 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Alex Yakunin
@@ -474,7 +474,7 @@ private static void PartiallyCopyTupleFast(PackedTuple source, PackedTuple targe
474474

475475
private static void CopyTupleWithMappingSlow(Tuple source, Tuple target, IReadOnlyList<int> map)
476476
{
477-
for (int targetIndex = 0; targetIndex < map.Count; targetIndex++) {
477+
for (int targetIndex = 0, count = map.Count; targetIndex < count; targetIndex++) {
478478
var sourceIndex = map[targetIndex];
479479
if (sourceIndex >= 0)
480480
CopyValue(source, sourceIndex, target, targetIndex);
@@ -492,7 +492,7 @@ private static void CopyTupleWithMappingFast(PackedTuple source, PackedTuple tar
492492

493493
private static void CopyTupleArrayWithMappingSlow(Tuple[] sources, Tuple target, Pair<int, int>[] map)
494494
{
495-
for (int targetIndex = 0; targetIndex < map.Length; targetIndex++) {
495+
for (int targetIndex = 0, length = map.Length; targetIndex < length; targetIndex++) {
496496
var sourceInfo = map[targetIndex];
497497
var sourceTupleIndex = sourceInfo.First;
498498
var sourceFieldIndex = sourceInfo.Second;
@@ -514,7 +514,7 @@ private static void CopyTupleArrayWithMappingFast(PackedTuple[] sources, PackedT
514514

515515
private static void Copy3TuplesWithMappingSlow(FixedList3<Tuple> sources, Tuple target, Pair<int, int>[] map)
516516
{
517-
for (int targetIndex = 0; targetIndex < map.Length; targetIndex++) {
517+
for (int targetIndex = 0, length = map.Length; targetIndex < length; targetIndex++) {
518518
var sourceInfo = map[targetIndex];
519519
var sourceTupleIndex = sourceInfo.First;
520520
var sourceFieldIndex = sourceInfo.Second;

0 commit comments

Comments
 (0)