Speed of csvReader

data pulverizer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 21 11:08:38 PST 2016


On Thursday, 21 January 2016 at 18:46:03 UTC, Justin Whear wrote:
> On Thu, 21 Jan 2016 18:37:08 +0000, data pulverizer wrote:
>
>> It's interesting that the output first array is not the same 
>> as the input
>
> byLine reuses a buffer (for speed) and the subsequent split 
> operation just returns slices into that buffer.  So when byLine 
> progresses to the next line the strings (slices) returned 
> previously now point into a buffer with different contents.  
> You should either use byLineCopy or .idup to create copies of 
> the relevant strings.  If your use-case allows for streaming 
> and doesn't require having all the data present at once, you 
> could continue to use byLine and just be careful not to refer 
> to previous rows.

Thanks. It now works with byLineCopy()

Time (s): 1.128


More information about the Digitalmars-d-learn mailing list