Re: fxcop

Gopal V <gopalv82-/[email protected]>
Newsgroups gmane.comp.gnu.dotgnu.developer
Message-ID <[email protected]>
Hi,

> Forgive my stupidity but ... How is a defined?

'a' is a String .. which is where this discussion
started .. ie comparing 2 strings is more costly than
comparing their lengths ... so for empty strings ,
check for Length == 0.

> >if(a == "")
> >
> What happens here if a is null?

evaluates to false ... (because null != "")

> >if(a != null && a.Length == 0)
> >
> And what happens here if a is null?

Obviously a!= null , short circuits the other
expression.

Since short circuited logical expressions came with
C , everybody assumes that a != null && a.Length == 0
will not throw a null ref exception, but that may
not always be the case in *all* languages. But in C#
it is.

Btw, the patch should be really interesting to 
potential cscc hackers as it clearly shows how the
tree is rewritten for optimisations.

Gopal


	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.