dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU] fxcop


From: Gopal V
Subject: Re: [DotGNU] fxcop
Date: Sun, 2 May 2004 00:32:56 -0700 (PDT)

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 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]