Skip to content

Commit b5c37da

Browse files
committed
Optimize IndexInfo.Columns to be Array instead of List<>
1 parent f63b07a commit b5c37da

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

Orm/Xtensive.Orm/Orm/Model/IndexInfo.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public sealed class IndexInfo : MappedNode
3535
private readonly IndexInfo declaringIndex;
3636
private double fillFactor;
3737
private string shortName;
38-
private ReadOnlyCollection<ColumnInfo> columns;
3938
private TupleDescriptor tupleDescriptor;
4039
private TupleDescriptor keyTupleDescriptor;
4140
private IReadOnlyList<TypeInfo> filterByTypes;
@@ -82,12 +81,7 @@ public ColumnGroup Group {
8281
/// <summary>
8382
/// Gets a collection of all the columns that are included into the index.
8483
/// </summary>
85-
public IReadOnlyList<ColumnInfo> Columns {
86-
[DebuggerStepThrough]
87-
get {
88-
return columns;
89-
}
90-
}
84+
public IReadOnlyList<ColumnInfo> Columns { [DebuggerStepThrough] get; private set; }
9185

9286
/// <summary>
9387
/// Gets a collection of columns that are included into the index as index key.
@@ -135,7 +129,7 @@ public TupleDescriptor KeyTupleDescriptor
135129
}
136130

137131
/// <summary>
138-
/// Gets the underlying indexes for this instance.
132+
/// Gets the underlying indexes for this instance.
139133
/// </summary>
140134
public CollectionBaseSlim<IndexInfo> UnderlyingIndexes
141135
{
@@ -339,8 +333,8 @@ public override void UpdateState()
339333
var lazy = new List<int>();
340334
var regular = new List<int>();
341335

342-
for (int i = 0; i < columns.Count; i++) {
343-
var item = columns[i];
336+
for (int i = 0, count = Columns.Count; i < count; i++) {
337+
var item = Columns[i];
344338
if (item.IsPrimaryKey || item.IsSystem)
345339
system.Add(i);
346340
else {
@@ -390,13 +384,9 @@ private void CreateTupleDescriptors()
390384

391385
private void CreateColumns()
392386
{
393-
var result = new List<ColumnInfo>(keyColumns.Count + valueColumns.Count);
394-
result.AddRange(keyColumns.Select(static pair => pair.Key));
395-
result.AddRange(valueColumns);
396-
columns = result.AsReadOnly();
387+
Columns = Array.AsReadOnly(KeyColumns.Select(static pair => pair.Key).Concat(ValueColumns).ToArray(KeyColumns.Count + ValueColumns.Count));
397388
}
398389

399-
400390
// Constructors
401391

402392
private IndexInfo()
@@ -456,7 +446,7 @@ public IndexInfo(TypeInfo reflectedType, IndexAttributes indexAttributes, IndexI
456446
filterExpression = baseIndex.FilterExpression;
457447
declaringIndex = baseIndex.DeclaringIndex;
458448
shortName = baseIndex.ShortName;
459-
449+
460450
UnderlyingIndexes.Add(baseIndex);
461451

462452
foreach (IndexInfo info in baseIndexes)

0 commit comments

Comments
 (0)