Memoize and other optimization.
David
d at dav1d.de
Fri Aug 17 02:45:38 PDT 2012
Am 17.08.2012 02:09, schrieb bearophile:
> David:
>
>> Is using std.functional.memoize useful for that function, or is the
>> lookup slower?
>
> This is hard to tell, in general you have to write two versions of your
> code, and time them.
I though there is a rule of thumb how many array lookups equal an AA
lookup, so I'll time it.
>> PS:/ I just noticed that I wanted to optimize "arr ~= …". Better using
>> a static array or std.array.appender with reserve?
>
> A static array, where usable, is faster because it has no resize costs.
> appender is supposed to be faster than ~= if you are appending a lot,
> but unfortunately this is not always true, and you have to time again.
So I'll go with a static array, thanks for your answer.
More information about the Digitalmars-d-learn
mailing list