https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71044

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Created attachment 38461
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38461&action=edit
Make directory iterators lazy

(In reply to Jonathan Wakely from comment #0)
> Directory iterators currently construct a path object on every increment.
> This means that incrementing a directory iterator five times then
> dereferencing it constructs five paths which are never used (and each one is
> eagerly split into components, allocating a container of paths!).
> Construction of the path could be postponed so that it's only done on
> dereference, so that the five increments are cheap. This has thread-safety
> consequences, as the dereference is a const operation and could be performed
> concurrently, so the lazy construction of the path needs to be synchronized.

As in the attached patch.

Reply via email to