> I agree that maybe it is more applicable for JIT to do all > optimizations, that however doesn't change the original question > regarding the number of boxings at the time Console.WriteLine executes > (be it JIT or CSC optimization). And if it is, statistically, worth the > effort, it would be of course a shame to box that integer. >
I'm at a bit of a loss to understand why it would be ok to *not* box that integer. WriteLine is expecting an object. It could in theory call GetType on the passed object therefore requiring it to definitely be a reference type - unless you think we should special case the known primitives (there is some code in place special casing situations like boxing Nullable<T>). Then we come back to Fabian's point - assuming you have a shared boxed int, how long do you expect to keep this shared int around? If not forever (which is possible if you think about the behaviour of interned strings) then you have just created a bunch of gen2 garbage that the GC will have to work very hard to collect. Regards Richard =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com