Speed of csvReader

Justin Whear via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 21 10:46:03 PST 2016


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.


More information about the Digitalmars-d-learn mailing list