Re: Efficient idiom for fastest code

2018-05-24 Thread biocyberman via Digitalmars-d-learn
On Wednesday, 23 May 2018 at 03:12:52 UTC, IntegratedDimensions wrote: On Wednesday, 23 May 2018 at 03:00:17 UTC, Nicholas Wilson wrote: [...] I knew someone was going to say that and I forgot to say DON'T! Saying to profile when I clearly said these ARE cases where they are slow is just mor

Re: Efficient idiom for fastest code

2018-05-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 23 May 2018 at 03:12:52 UTC, IntegratedDimensions wrote: I knew someone was going to say that and I forgot to say DON'T! Saying to profile when I clearly said these ARE cases where they are slow is just moronic. Please don't use default answers to arguments. This was a general

Re: Efficient idiom for fastest code

2018-05-23 Thread IntegratedDimensions via Digitalmars-d-learn
On Wednesday, 23 May 2018 at 10:55:02 UTC, Malte wrote: On Wednesday, 23 May 2018 at 02:24:08 UTC, IntegratedDimensions wrote: [...] I would just do [...] [...] Thanks, I didn't think about using a for loop like that. While it is not the most general it does solve the specific case for

Re: Efficient idiom for fastest code

2018-05-23 Thread Malte via Digitalmars-d-learn
On Wednesday, 23 May 2018 at 02:24:08 UTC, IntegratedDimensions wrote: In some cases the decision holds for continuous ranges. For some 0 <= n <= N the decision is constant, but n is arbitrary(determined by unknown factors at compile time). One can speed up the routine by using something akin

Re: Efficient idiom for fastest code

2018-05-22 Thread IntegratedDimensions via Digitalmars-d-learn
On Wednesday, 23 May 2018 at 03:00:17 UTC, Nicholas Wilson wrote: On Wednesday, 23 May 2018 at 02:24:08 UTC, IntegratedDimensions wrote: Many times in expensive loops one must make decisions. Decisions must be determined and the determination costs. for(int i = 0; i < N; i++) { if(decisi

Re: Efficient idiom for fastest code

2018-05-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 23 May 2018 at 02:24:08 UTC, IntegratedDimensions wrote: Many times in expensive loops one must make decisions. Decisions must be determined and the determination costs. for(int i = 0; i < N; i++) { if(decision(i)) A; else B; } the if statement costs N times the cycle cost.

Efficient idiom for fastest code

2018-05-22 Thread IntegratedDimensions via Digitalmars-d-learn
Many times in expensive loops one must make decisions. Decisions must be determined and the determination costs. for(int i = 0; i < N; i++) { if(decision(i)) A; else B; } the if statement costs N times the cycle cost. In some cases the decision holds for continuous ranges. For some 0 <=