automate tuple creation

Ali Çehreli acehreli at yahoo.com
Wed Jan 19 23:29:55 UTC 2022


On 1/19/22 15:21, H. S. Teoh wrote:
 > On Wed, Jan 19, 2022 at 02:33:02PM -0800, Ali Çehreli via 
Digitalmars-d-learn wrote:
 > [...]
 >> // Returning a dynamically allocated array looks expensive
 >> // here. Why not use a struct or std.typecons.Tuple instead?
 >
 > Premature optimization. ;-)

Not in this case because I am pointing at premature pessimization. :) 
There is no reason to use two-element dynamic arrays when uint[2], 
Tuple!(uint, uint), and structs are available.

 > There's nothing wrong with allocating an
 > array.

Agreed.

Ali



More information about the Digitalmars-d-learn mailing list