Skip to content

Commit 4bd597f

Browse files
authoredFeb 2, 2025··
Always inline number conversions (#112061)
* Mark TryConvertFrom as AggressiveInlining * Cover TryConvertTo
1 parent 5a8f405 commit 4bd597f

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed
 

‎src/libraries/System.Private.CoreLib/src/System/Decimal.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,7 @@ static bool INumberBase<decimal>.TryConvertFromTruncating<TOther>(TOther value,
15731573
return TryConvertFrom(value, out result);
15741574
}
15751575

1576+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
15761577
private static bool TryConvertFrom<TOther>(TOther value, out decimal result)
15771578
where TOther : INumberBase<TOther>
15781579
{
@@ -1722,6 +1723,7 @@ static bool INumberBase<decimal>.TryConvertToTruncating<TOther>(decimal value, [
17221723
return TryConvertTo(value, out result);
17231724
}
17241725

1726+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
17251727
private static bool TryConvertTo<TOther>(decimal value, [MaybeNullWhen(false)] out TOther result)
17261728
where TOther : INumberBase<TOther>
17271729
{

‎src/libraries/System.Private.CoreLib/src/System/Double.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,7 @@ static bool INumberBase<double>.TryConvertFromTruncating<TOther>(TOther value, o
12291229
return TryConvertFrom(value, out result);
12301230
}
12311231

1232+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
12321233
private static bool TryConvertFrom<TOther>(TOther value, out double result)
12331234
where TOther : INumberBase<TOther>
12341235
{
@@ -1378,6 +1379,7 @@ static bool INumberBase<double>.TryConvertToTruncating<TOther>(double value, [Ma
13781379
return TryConvertTo(value, out result);
13791380
}
13801381

1382+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
13811383
private static bool TryConvertTo<TOther>(double value, [MaybeNullWhen(false)] out TOther result)
13821384
where TOther : INumberBase<TOther>
13831385
{

‎src/libraries/System.Private.CoreLib/src/System/Half.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ static bool INumberBase<Half>.TryConvertFromTruncating<TOther>(TOther value, out
19281928
return TryConvertFrom(value, out result);
19291929
}
19301930

1931+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
19311932
private static bool TryConvertFrom<TOther>(TOther value, out Half result)
19321933
where TOther : INumberBase<TOther>
19331934
{
@@ -2077,6 +2078,7 @@ static bool INumberBase<Half>.TryConvertToTruncating<TOther>(Half value, [MaybeN
20772078
return TryConvertTo(value, out result);
20782079
}
20792080

2081+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
20802082
private static bool TryConvertTo<TOther>(Half value, [MaybeNullWhen(false)] out TOther result)
20812083
where TOther : INumberBase<TOther>
20822084
{

‎src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,7 @@ static bool INumberBase<NFloat>.TryConvertFromTruncating<TOther>(TOther value, o
14101410
return TryConvertFrom(value, out result);
14111411
}
14121412

1413+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
14131414
private static bool TryConvertFrom<TOther>(TOther value, out NFloat result)
14141415
where TOther : INumberBase<TOther>
14151416
{
@@ -1649,6 +1650,7 @@ static bool INumberBase<NFloat>.TryConvertToTruncating<TOther>(NFloat value, [Ma
16491650
return TryConvertTo(value, out result);
16501651
}
16511652

1653+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
16521654
private static bool TryConvertTo<TOther>(NFloat value, [MaybeNullWhen(false)] out TOther result)
16531655
where TOther : INumberBase<TOther>
16541656
{

‎src/libraries/System.Private.CoreLib/src/System/Single.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,7 @@ static bool INumberBase<float>.TryConvertFromTruncating<TOther>(TOther value, ou
12481248
return TryConvertFrom(value, out result);
12491249
}
12501250

1251+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
12511252
private static bool TryConvertFrom<TOther>(TOther value, out float result)
12521253
where TOther : INumberBase<TOther>
12531254
{
@@ -1397,6 +1398,7 @@ static bool INumberBase<float>.TryConvertToTruncating<TOther>(float value, [Mayb
13971398
return TryConvertTo(value, out result);
13981399
}
13991400

1401+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
14001402
private static bool TryConvertTo<TOther>(float value, [MaybeNullWhen(false)] out TOther result)
14011403
where TOther : INumberBase<TOther>
14021404
{

0 commit comments

Comments
 (0)
Please sign in to comment.