Old problem with performance

Weed resume755 at mail.ru
Sun Feb 8 18:59:50 PST 2009


Walter Bright пишет:
> Frits van Bommel wrote:
>> Which helps (a bit) with the two instances allocated in main(), but is
>> rather unhelpful with the 100_000_000 allocated in opAdd() (they're
>> returned)...
> 
> The use of classes in this example is like using a screwdriver as a
> hammer. It'll work in a pinch, but a hammer works a lot better. If
> you're allocating 100_000_000 classes in a tight loop, some refactoring
> looks to be in order.
> 
> In particular, classes are *meant* to be used as reference types, but
> the program is trying to treat them as value types.

But without such types the bulky code turns out
(examples in this branch already presented)

> Virtual functions
> are orthogonal to what value types are - a continuing problem C++
> programs have is conflating value types with reference types.

The compiler cannot optimize such code? No

We have virtual machine for fast allocations of memory at such
heavy using of objects? No

Perfectly - it is necessary to leave this question to the programmer:
the class will be stored in a stack or in a heap is better will solve
the programmer instead of the compiler.

It is impossible to lose to an C++ in what.



More information about the Digitalmars-d mailing list