Memoize and other optimization.
bearophile
bearophileHUGS at lycos.com
Thu Aug 16 17:09:27 PDT 2012
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.
> 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.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list