Tiny optimization
This commit is contained in:
1 parent
e5486af49d
commit
9e5ee36e6e
1 file changed
+2
-3
@@ -15,7 +15,6 @@ internal struct MutableUInt128
|
|||||||
|
|
||||||
public MutableUInt128(ulong value)
|
public MutableUInt128(ulong value)
|
||||||
{
|
{
|
||||||
High = 0UL;
|
|
||||||
Low = value;
|
Low = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +52,7 @@ internal struct MutableUInt128
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public UInt128 ToUInt128() => ((UInt128)High << 64) | Low;
|
public readonly UInt128 ToUInt128() => ((UInt128)High << 64) | Low;
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Add(ulong value)
|
public void Add(ulong value)
|
||||||
@@ -71,10 +70,10 @@ internal struct MutableUInt128
|
|||||||
public void Add(in MutableUInt128 value)
|
public void Add(in MutableUInt128 value)
|
||||||
{
|
{
|
||||||
ulong low = Low + value.Low;
|
ulong low = Low + value.Low;
|
||||||
|
Low = low;
|
||||||
ulong carry = low < Low ? 1UL : 0UL;
|
ulong carry = low < Low ? 1UL : 0UL;
|
||||||
ulong high = High + value.High + carry;
|
ulong high = High + value.High + carry;
|
||||||
|
|
||||||
Low = low;
|
|
||||||
High = high;
|
High = high;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user