Skip to content

Commit c1fa024

Browse files
committed
Calc ValueFieldAccessor.Rank() using BitOperations.Log2()
1 parent 972e3ed commit c1fa024

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Orm/Xtensive.Orm/Tuples/Packed/PackedFieldAccessor.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created: 2013.01.22
66

77
using System;
8+
using System.Numerics;
89

910
namespace Xtensive.Tuples.Packed
1011
{
@@ -144,15 +145,8 @@ internal abstract class ValueFieldAccessor : PackedFieldAccessor
144145
{
145146
public Type FieldType { get; protected set; }
146147

147-
private static int GetRank(int bitSize)
148-
{
149-
var rank = 0;
150-
while ((bitSize >>= 1) > 0) {
151-
rank++;
152-
}
153-
154-
return rank;
155-
}
148+
private static int GetRank(int bitSize) =>
149+
BitOperations.Log2((uint)bitSize);
156150

157151
protected ValueFieldAccessor(int bitCount, byte index)
158152
: base(GetRank(bitCount), index)

0 commit comments

Comments
 (0)