Change representation of dynamic arrays?

David Brown dlang at davidb.org
Sat Oct 20 05:19:35 PDT 2007


On Sat, Oct 20, 2007 at 01:16:54AM -0700, Walter Bright wrote:

> Divides are expensive. It's mitigated by:
> 1) most of the time, it's 1
> 2) most of the rest of the time, it's a power of 2 and optimized to shift
> 3) some of the rest of the time, it can be skipped as it divides then
> multiples by the same amount.

At least with the gcc backend, divides by constants almost always turn into
multiplies of strange constants, or weird tricks with shifts and
subtracts/adds, depending on what the compiler things will be better.

David



More information about the Digitalmars-d mailing list