https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90634
--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> --- Author: redi Date: Tue May 28 20:48:31 2019 New Revision: 271719 URL: https://gcc.gnu.org/viewcvs?rev=271719&root=gcc&view=rev Log: PR libstdc++/90634 reduce allocations in filesystem::path construction Backport from mainline 2019-05-28 Jonathan Wakely <jwak...@redhat.com> PR libstdc++/90634 * include/experimental/bits/fs_path.h (path::path(path&&)): Only call _M_split_cmpts() for a path with multiple components. (path::_S_is_dir_sep()): Add missing 'static' keyword to function. * src/filesystem/path.cc (path::_M_split_cmpts()): Count number of components and reserve space in vector. Return early when there is only one component. * testsuite/27_io/filesystem/path/construct/90634.cc: New test. * testsuite/experimental/filesystem/path/construct/90634.cc: New test. Added: branches/gcc-9-branch/libstdc++-v3/testsuite/27_io/filesystem/path/construct/90634.cc branches/gcc-9-branch/libstdc++-v3/testsuite/experimental/filesystem/path/construct/90634.cc Modified: branches/gcc-9-branch/libstdc++-v3/ChangeLog branches/gcc-9-branch/libstdc++-v3/include/experimental/bits/fs_path.h branches/gcc-9-branch/libstdc++-v3/src/filesystem/path.cc