Fastest Way to Append Multiple Elements to an Array

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Dec 18 07:12:38 PST 2014


On Wednesday, 17 December 2014 at 12:30:37 UTC, Tobias Pankrath 
wrote:
>> void append(T, Args...)(ref T[] arr, auto ref Args args){
>> {
>>   static if (args.length == 1)
>>      arr ~= args[0];     // inlined
>>   else{
>>      arr.length += args.length;
>>      foreach(i, e; args)
>>         arr[$ - args.length + i] = e;
>>   }
>> }

Is it un-Phobos-like to make append return a reference to data 
like at

https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L1605


More information about the Digitalmars-d-learn mailing list