Skip to content

Commit a6a742c

Browse files
committed
HashSet is better than Dictionary
1 parent 4ea9e4a commit a6a742c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

BTDB/ODBLayer/RelationVersionInfo.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,20 @@ void CreateSecondaryKeyInfo(List<Tuple<int, IList<SecondaryKeyAttribute>>> attri
115115
Name = indexName,
116116
Fields = new List<FieldId>()
117117
};
118-
var usedPKFields = new Dictionary<uint, object>();
118+
var usedPKFields = new HashSet<uint>();
119119
foreach (var attr in orderedAttrs)
120120
{
121121
for (uint i = 1; i <= attr.Item2.IncludePrimaryKeyOrder; i++)
122122
{
123-
usedPKFields.Add(i, null);
123+
usedPKFields.Add(i);
124124
var pi = PrimaryKeyFields.Span.IndexOf(primaryKeyFields[i]);
125125
info.Fields.Add(new FieldId(true, (uint)pi));
126126
}
127127

128128
if (attr.Item1 < 0)
129129
{
130130
var pkOrder = (uint)-attr.Item1;
131-
usedPKFields.Add(pkOrder, null);
131+
usedPKFields.Add(pkOrder);
132132
var pi = PrimaryKeyFields.Span.IndexOf(primaryKeyFields[pkOrder]);
133133
info.Fields.Add(new FieldId(true, (uint)pi));
134134
}
@@ -143,7 +143,7 @@ void CreateSecondaryKeyInfo(List<Tuple<int, IList<SecondaryKeyAttribute>>> attri
143143
{
144144
if (pk.Value.InKeyValue)
145145
continue;
146-
if (!usedPKFields.ContainsKey(pk.Key))
146+
if (!usedPKFields.Contains(pk.Key))
147147
info.Fields.Add(new FieldId(true, (uint)PrimaryKeyFields.Span.IndexOf(primaryKeyFields[pk.Key])));
148148
}
149149

0 commit comments

Comments
 (0)