Efficiency of immutable vs mutable

2015-11-02 Thread Andrew via Digitalmars-d-learn
I've written a short D program that involves many lookups into a static array. When I make the array immutable the program runs faster. This must mean that immutable is more than a restriction on access, it must affect the compiler output. But why and how? Thanks Andrew

Re: Efficiency of immutable vs mutable

2015-11-02 Thread TheFlyingFiddle via Digitalmars-d-learn
On Tuesday, 3 November 2015 at 03:16:07 UTC, Andrew wrote: I've written a short D program that involves many lookups into a static array. When I make the array immutable the program runs faster. This must mean that immutable is more than a restriction on access, it must affect the compiler out

Re: Efficiency of immutable vs mutable

2015-11-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 03, 2015 03:16:06 Andrew via Digitalmars-d-learn wrote: > I've written a short D program that involves many lookups into a > static array. When I make the array immutable the program runs > faster. This must mean that immutable is more than a restriction > on access, it must a

Re: Efficiency of immutable vs mutable

2015-11-03 Thread Andrew via Digitalmars-d-learn
This: On Tuesday, 3 November 2015 at 04:08:09 UTC, TheFlyingFiddle wrote: __gshared char[4] lookup = ['a', 't', 'g', 'c]; Has the same efficiency gain as immutable, so it looks like a thread-local vs global difference and the extra cost is going through the thread-local lookup. Thanks

Re: Efficiency of immutable vs mutable

2015-11-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 03, 2015 18:44:06 Andrew via Digitalmars-d-learn wrote: > This: > > On Tuesday, 3 November 2015 at 04:08:09 UTC, TheFlyingFiddle > wrote: > > __gshared char[4] lookup = ['a', 't', 'g', 'c]; > > Has the same efficiency gain as immutable, so it looks like a > thread-local vs glob