Constants for boxed true and false values #4671
Replies: 3 comments 5 replies
-
This sounds like a suggestion for the https://github.com/dotnet/runtime repository. To me it sounds like it could be a JIT optimization to detect when a |
Beta Was this translation helpful? Give feedback.
-
This would be very problematic to do now since using System;
using System.Runtime.CompilerServices;
class Program
{
private static readonly object BoxedTrue = true;
static void Main()
{
Console.WriteLine(BoxedTrue); //'True'
Unsafe.Unbox<bool>(BoxedTrue) = false;
Console.WriteLine(BoxedTrue); //'False'
}
} See also the discussion at dotnet/runtime#28278 |
Beta Was this translation helpful? Give feedback.
-
Duplicate of dotnet/runtime#47596? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We have performance experts going through parts of our code base looking for memory allocations for boxed 'true' and 'false' boolean values and creating constants for the boxed values.
Isn't this something that could be available in the runtime either as constants or as part of the compiler to optimize this so:
Beta Was this translation helpful? Give feedback.
All reactions