diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2015-05-01 21:05:42 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2015-05-01 21:05:42 +0100 |
commit | 4ad376273d70e96e1b7d3eac126c3e1598246d5c (patch) | |
tree | babb0fe93b9a0f6cacd03d38f0b9ddd94eadfb77 | |
parent | bf53e6a9dd3739538841c4f8f141b1fdedc1eddf (diff) | |
download | gcc-4ad376273d70e96e1b7d3eac126c3e1598246d5c.zip gcc-4ad376273d70e96e1b7d3eac126c3e1598246d5c.tar.gz gcc-4ad376273d70e96e1b7d3eac126c3e1598246d5c.tar.bz2 |
* src/filesystem/path.cc (path::compare): Do not copy strings.
From-SVN: r222704
-rw-r--r-- | libstdc++-v3/ChangeLog | 2 | ||||
-rw-r--r-- | libstdc++-v3/src/filesystem/path.cc | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7e07005..a955a0f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,7 @@ 2015-05-01 Jonathan Wakely <jwakely@redhat.com> + * src/filesystem/path.cc (path::compare): Do not copy strings. + * acinclude.m4 (GLIBCXX_ENABLE_FILESYSTEM_TS): Disable when <dirent.h> is not available. (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for fchmodat. diff --git a/libstdc++-v3/src/filesystem/path.cc b/libstdc++-v3/src/filesystem/path.cc index cc5780f..7924732 100644 --- a/libstdc++-v3/src/filesystem/path.cc +++ b/libstdc++-v3/src/filesystem/path.cc @@ -107,17 +107,23 @@ namespace int path::compare(const path& p) const noexcept { + struct CmptRef + { + const path* ptr; + const string_type& native() const noexcept { return ptr->native(); } + }; + if (_M_type == _Type::_Multi && p._M_type == _Type::_Multi) return do_compare(_M_cmpts.begin(), _M_cmpts.end(), p._M_cmpts.begin(), p._M_cmpts.end()); else if (_M_type == _Type::_Multi) { - _Cmpt c[1] = { { p._M_pathname, p._M_type, 0 } }; + CmptRef c[1] = { { &p } }; return do_compare(_M_cmpts.begin(), _M_cmpts.end(), c, c+1); } else if (p._M_type == _Type::_Multi) { - _Cmpt c[1] = { { _M_pathname, _M_type, 0 } }; + CmptRef c[1] = { { this } }; return do_compare(c, c+1, p._M_cmpts.begin(), p._M_cmpts.end()); } else |