On Monday, 10 April 2023 at 01:01:59 UTC, Steven Schveighoffer
wrote:
On 4/9/23 9:16 AM, Ali Çehreli wrote:
On 4/8/23 21:38, ikelaiah wrote:
> I will modify the code to construct it twice.
Multiple iterations of dirEntries can produce different
results, which may or may not be what your program will be
happy with.
Sticking an .array at the end will iterate a single time and
maintain the list forever because .array returns an array. :)
auto entries = dirEntries(/* ... */).array;
I'd be cautious of that. I don't know what the underlying code
uses, it may reuse buffers for e.g. filenames to avoid
allocation.
If you are confident the directory contents won't change in
that split-second, then I think iterating twice is fine.
-Steve
Steve,
The Rmd files are not on a network drive, but saved locally.
So, I'm confident, the files won't change in a split-second.
-ikelaiah.