Unity-Technologies/mono — pull request #109 by richard-fine (2014-03-02 04:38:50+00:00)
Title: Use constrained virtual method call for value-typed instances instead of boxing

Aimed at fixing bug #594320. The idea is to use a constrained virtual call if possible, instead of a boxed reference - this was new in CLR 2.0 (which is why it was never done in the first place I guess).

Initial testing suggests that this works fine - it gets rid of the 24 byte allocation produced by foreach() loops over collections - but I've not been able to get the MCS test suite running smoothly so I'm not sure that it's entirely safe. It seems like a few more tests fail with the change than without but I can't get stable results switching back and forth. Hopefully your test suite setup is more reliable and you can verify that it doesn't break things...