Profiling graph library
bearophile
bearophileHUGS at lycos.com
Wed Jul 31 07:59:31 PDT 2013
Joseph Rushton Wakeling:
> But most likely the best compromise solution is as you
> suggest a buffer, with the instruction ".dup the result
> if you want it to be persistent".
In my library code often I do the opposite: I add a template
boolean switch named as "doCopy" that defaults to true. If it's
true, the function copies the buffer. So if you don't know what
you are doing, or you don't care about performance (and this
happens often), it's safer. When you know what you are doing or
your profiling (or your experience) tells you you want more
performance, you call the function with a false doCopy, and it
doesn't allocate a new buffer.
This is the design I suggested for File.byLine() but Andrei ha
preferred a simpler design that doesn't create a new buffer for
each line.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list