PR libstdc++/90634 reduce allocations in filesystem::path construction
authorJonathan Wakely <jwakely@redhat.com>
Tue, 28 May 2019 19:39:48 +0000 (20:39 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 28 May 2019 19:39:48 +0000 (20:39 +0100)
commit441ed45ca2abe83f78be48e6ca816e9ec6e27222
treec1876a43ff7fce4b9302209be2ba1be30429da12
parentd9b401df8f3eda8bcb647cae0c07c9bd19bff00b
PR libstdc++/90634 reduce allocations in filesystem::path construction

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.

From-SVN: r271717
libstdc++-v3/ChangeLog
libstdc++-v3/include/experimental/bits/fs_path.h
libstdc++-v3/src/filesystem/path.cc
libstdc++-v3/testsuite/27_io/filesystem/path/construct/90634.cc [new file with mode: 0644]
libstdc++-v3/testsuite/experimental/filesystem/path/construct/90634.cc [new file with mode: 0644]