emplace, scope, enforce [Was: Re: Manual...]

Rory Mcguire rjmcguire at gm_no_ail.com
Wed Jul 21 11:59:54 PDT 2010


Dmitry Olshansky wrote:

> now replace the orignal while loop with this:
> while (i < N) {
> auto testObject = Scoped!Test(i, i, i, i, i, i);
> //assuming we have aforementioned evil function func(Test t),
> that keeps global reference to t.
> //fun(testObject); //uncoment to get an compile error - type
> mismatch
> testObject.doSomething(i, i, i, i, i, i);
> testObject.doSomething(i, i, i, i, i, i);
> testObject.doSomething(i, i, i, i, i, i);
> testObject.doSomething(i, i, i, i, i, i);
> i++;
> }

With your code I `time` reports the below timings on my machine:
real	0m19.658s
user	0m19.590s
sys	0m0.010s

compared to:
real	0m9.122s
user	0m9.090s
sys	0m0.000s

with bearofiles original version. With -O -release its about 4 seconds 
faster for each.


More information about the Digitalmars-d mailing list