Skip to content

Commit 70845b6

Browse files
committed
ParameterBinding normalization use arrays instead of HashSet
- no hash calculations, - no overhead of hashed - if we want to change return type of the method to something more specific like IReadOnlyCollection or IReadOnlyList, then having arrays will help
1 parent bcc4620 commit 70845b6

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Orm/Xtensive.Orm/Orm/Providers/Requests/ParameterBinding.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Created by: Dmitri Maximov
55
// Created: 2008.09.26
66

7+
using System;
78
using System.Collections.Generic;
89
using System.Linq;
910
using Xtensive.Core;
@@ -26,7 +27,12 @@ public abstract class ParameterBinding
2627
public static IEnumerable<T> NormalizeBindings<T>(IEnumerable<T> bindings)
2728
where T : ParameterBinding
2829
{
29-
return bindings!=null ? new HashSet<T>(bindings) : Enumerable.Empty<T>();
30+
if (bindings is null)
31+
return Array.Empty<T>();
32+
var normalized = bindings.ToArray();
33+
if (normalized.Length == 0)
34+
return Array.Empty<T>();
35+
return normalized;
3036
}
3137

3238

0 commit comments

Comments
 (0)