staticIndexOf is incredibly slow and memory intensive

Artur Skawina art.08.09 at gmail.com
Sun Aug 26 15:44:55 PDT 2012


On 08/27/12 00:31, Philippe Sigaud wrote:
> On Sun, Aug 26, 2012 at 11:58 PM, Artur Skawina <art.08.09 at gmail.com> wrote:
> 
>>    template staticIndexOf(T, TS...) {
>>       enum staticIndexOf = {
>>          foreach(size_t i, I; TS)
>>             static if (is(typeof(T == I)) && is(T == I))
>>                return i;
>>          return -1;
>>       }();
>>    }
> 
> Is the is(typeof(T == I)) really necessary? If T == I is an error,
> then is() returns false, or am I mistaken?
> 

It didn't look necessary to me either; i took the condition verbatim
from Andrej's example. Removing the check made no difference to
performance, so i kept it to minimize the diff between both versions.

artur


More information about the Digitalmars-d mailing list