Inherent code performance advantages of D over C?
    Jacob Carlborg 
    doob at me.com
       
    Mon Dec  9 08:06:10 PST 2013
    
    
  
On 2013-12-09 09:45, Walter Bright wrote:
> Try this:
>
>    pure int foo (int a, int b) nothrow {
>      return a + b;
>    }
>
>    int test() {
>      return foo(1, 2) + foo(1, 2);
>    }
>
> Compile with:
>
>    dmd foo -O -release -c
>
> And dump the assembly:
>
>              push    EAX
>              mov     EAX,2
>              push    1
>              call    near ptr _D3foo3fooFNaNbiiZi
>              add     EAX,EAX
>              pop     ECX
>              ret
>
> Granted, more cases can be done, but it *does* take advantage of purity
> here and there.
Yeah, that worked. I tried to do as simple case I could think of.
-- 
/Jacob Carlborg
    
    
More information about the Digitalmars-d
mailing list