Skip to content

Commit 30441d6

Browse files
committed
ReverseList() instead of List.Reverse() for clear enumeration purposes
ReverseList uses backwards for, instead of true reverse
1 parent db538f3 commit 30441d6

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

Orm/Xtensive.Orm/Orm/Building/Builders/PartialIndexFilterBuilder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ protected override Expression VisitMemberAccess(MemberExpression originalMemberA
120120
}
121121
if (memberAccessSequence.Count==0 || !IsEntityParameter(memberAccess.Expression))
122122
return base.VisitMemberAccess(originalMemberAccess);
123-
memberAccessSequence.Reverse();
124-
var fieldName = StringExtensions.Join(".", memberAccessSequence.Select(item => item.Member.Name));
123+
var fieldName = StringExtensions.Join(".", memberAccessSequence.ReverseList().Select(item => item.Member.Name));
125124
var field = reflectedType.Fields[fieldName];
126125
if (field==null)
127126
throw UnableToTranslate(originalMemberAccess, Strings.MemberAccessSequenceContainsNonPersistentFields);

Orm/Xtensive.Orm/Orm/Internals/SortingPersistActionGenerator.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2012 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2012-2024 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Denis Krjuchkov
55
// Created: 2012.02.22
66

@@ -182,8 +182,7 @@ where association.OwnerField.IsEntity
182182
if (result.HasLoops) {
183183
sortedNodes = result.SortedNodes.Union(result.LoopNodes).ToList();
184184
var loopNodes = result.LoopNodes.ToDictionary(el => el as Collections.Graphs.Node);
185-
notBreakedEdges.Reverse();
186-
var loopEdgeForBreak = notBreakedEdges.First(edge => loopNodes.ContainsKey(edge.Source) && loopNodes.ContainsKey(edge.Target));
185+
var loopEdgeForBreak = notBreakedEdges.ReverseList().First(edge => loopNodes.ContainsKey(edge.Source) && loopNodes.ContainsKey(edge.Target));
187186
result.BrokenEdges.Add(loopEdgeForBreak);
188187
}
189188
else

Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlActionTranslator.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2009-2020 Xtensive LLC.
1+
// Copyright (C) 2009-2024 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: Ivan Galkin
@@ -845,13 +845,11 @@ private void ProcessClearAncestorsActions(List<DataAction> originalActions, bool
845845
if (referencedNode!=null && referencingNode!=null)
846846
new NodeConnection<TableInfo, ForeignKeyInfo>(referencedNode, referencingNode, foreignKey).BindToNodes();
847847
}
848-
List<NodeConnection<TableInfo, ForeignKeyInfo>> edges;
849-
var sortedTables = TopologicalSorter.Sort(nodes, out edges);
850-
sortedTables.Reverse();
848+
var sortedTables = TopologicalSorter.Sort(nodes, out List<NodeConnection<TableInfo, ForeignKeyInfo>> edges);
851849
// TODO: Process removed edges
852850

853851
// Build DML commands
854-
foreach (var table in sortedTables) {
852+
foreach (var table in sortedTables.ReverseList()) {
855853
var tableRef = SqlDml.TableRef(FindTable(table));
856854
var delete = SqlDml.Delete(tableRef);
857855
var typeIds = deleteActions[table];

0 commit comments

Comments
 (0)