Unchecked C# keyword

Nov 9, 2010 at 2:39 PM
Edited Nov 9, 2010 at 2:40 PM

I just seen this today, never heard of the unchecked structure in C#. I did some initial tests and I did see a very* small performance increase inside loops. Balder might have many situations where this could be used to help increase performance. Such as texture mapping or other calculations where the likelihood of overflow is low. More testing needs to be done, and with silverlight too. 

Just wanted to pass this along, every little bit helps!

http://msdn.microsoft.com/en-us/library/a569z7k8.aspx

 

*very very very   (but in situations where there are loops in loops it might be worth it)

Coordinator
Nov 10, 2010 at 7:08 AM

This is very interesting for the inner parts of the engine - the drawing of pixels. 

Thanks for the tip - I vaguely recall the keyword, but thats just about it. 

Nov 10, 2010 at 6:43 PM

I should have done a bit more research before I posted. C# has all overflow checking off by default.  So, using an unchecked block probably won't have any effect.  Any performance increase I seen was probably due to invalid testing procedures :(   Ahh well.

http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx

Coordinator
Nov 11, 2010 at 5:32 AM

Too bad - was getting my hopes up for a good performance improvement with little effort.. :) 

Ahh.. Well..  Have to do it the hard way then. I guess.. :)