Is variable assignment expensive compared to a null check? For example, is it worth checking that foo is not null before assigning it null?
if (foo != null)
If you have a decent compiler they will generate identical code. If you have a crappy compiler the one with the if will be worse. On 2009 hardware assignments to variables are very cheap, and conditional branches can sometimes be expensive.
if