Re: Why is "False" = "-1"?

From: MikeD (nobody_at_nowhere.edu)
Date: 07/25/04


Date: Sun, 25 Jul 2004 11:09:30 -0400


"Duane Bozarth" <dp_bozarth@swko.dot.net> wrote in message
news:4103C7D3.2333083F@swko.dot.net...

> In a nutshell, writing "If A Then" is <precisely> identical to writing
> "If A<>0 Then" and will generate the same code and therefore the same
> execution time. (Excepting perhaps for a <very> dumb compiler and I
> believe Dan's article shows that the VB compiler isn't that
> dumb--actually a couple of his examples show better code generation than
> I had suspected). This is conclusion can be generalized to cover any
> and all of the cases/pseudo-examples you've previously provided--they
> all boil down to either an eq or ne and there has to be something for
> the machine instruction to compare to--whether it's zero or nonzero
> makes no difference.

OK. I can buy that. It was many years ago that I had heard and read (from
many different sources) that 'If A Then" executed quicker. I can see how
that may have been the case prior to VB having native code compilation, but
with native code compilation, it is no longer true (because native code
compilation does optimize the code just as you say). In all honesty, I never
gave it a whole lot of thought.

Mike



Relevant Pages

  • Re: huge array
    ... It alwasy has been run as native code. ... |> transformed from plain VB code or from any other language, ... parsing and execution are two separate steps. ... | stage of compilation - which is the generation of IL (a binary, ...
    (microsoft.public.vb.general.discussion)
  • Re: huge array
    ... or do you know a CPU which can handle something like "FOR I = 1 TO ... There is a huge difference between interpeted code and native code. ... parsing and execution are two separate steps. ... compilation happens in two phases ...
    (microsoft.public.vb.general.discussion)
  • Re: huge array
    ... Of course is always any code executing on a CPU a native code which has been ... There is a huge difference between interpeted code and native code. ... parsing and execution are two separate steps. ... stage of compilation - which is the generation of IL (a binary, ...
    (microsoft.public.vb.general.discussion)
  • Java native code compilation
    ... I was just reading some stuff on a Java forum about compilation to ... native code. ...
    (comp.lang.java.programmer)
  • Re: [SLE] Clearing up the FUD on CLI/Mono
    ... Static compilation to native code as gcj does it ... native code compilation has optimization ... For all practial purposes and for a sizeable majority of programs, Java ...
    (SuSE)