Old problem with performance

Weed resume755 at mail.ru
Sun Feb 8 19:05:27 PST 2009


Radu пишет:

> While nor so orthodox, this improves the situation a bit:
> 
> template stackAllocator(T) {
>    new(size_t size, void* sp = alloca(T.classinfo.init.length)) {
>        return sp;
>    }
> 
>    delete(void* ptr) {
>    }
> }
> 
> final class C {
>    int i;
>    real[5] unused; // to prevent returning this object in registers
> 
>    C opAdd(C src) {
>        auto ret = new C;
>        ret.i = i + src.i;
>        return ret;
>    }
> 
>    mixin stackAllocator!(C);
> 
> }
> 
> Radu

If the used object it is impossible to change? It is written by other
person, for example?

And, we all will take for a rule in each object using overload to add
stackAllocator?



More information about the Digitalmars-d mailing list