aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-12-18 15:52:37 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2018-12-18 15:52:37 +0000
commit8d53154813367d0745c89f975b8dbc00bd032afc (patch)
treef7b3487499bd4adf281125049532d674e613ecdc
parent36313a6bce37f7eabc64c66f216ff0b2adb12ed7 (diff)
downloadgcc-8d53154813367d0745c89f975b8dbc00bd032afc.zip
gcc-8d53154813367d0745c89f975b8dbc00bd032afc.tar.gz
gcc-8d53154813367d0745c89f975b8dbc00bd032afc.tar.bz2
Micro-optimization to avoid creating temporary path
Now that path::operator/=(basic_string_view<value_type>) works directly from the string argument, instead of constructing a temporary path from the string, it's potentially more efficient to do 'path(x) /= s' instead of 'x / s'. This changes the only relevant place in the library. * src/filesystem/std-dir.cc (filesystem::_Dir::advance): Append string to lvalue to avoid creating temporary path. From-SVN: r267236
-rw-r--r--libstdc++-v3/ChangeLog3
-rw-r--r--libstdc++-v3/src/filesystem/std-dir.cc4
2 files changed, 6 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d61d4cc..eefc953 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,8 @@
2018-12-18 Jonathan Wakely <jwakely@redhat.com>
+ * src/filesystem/std-dir.cc (filesystem::_Dir::advance): Append
+ string to lvalue to avoid creating temporary path.
+
* include/bits/fs_path.h (path::compare(const string_type&))
(path::compare(const value_type*)): Add noexcept and construct a
string view to compare to instead of a path.
diff --git a/libstdc++-v3/src/filesystem/std-dir.cc b/libstdc++-v3/src/filesystem/std-dir.cc
index 038f635..216182a 100644
--- a/libstdc++-v3/src/filesystem/std-dir.cc
+++ b/libstdc++-v3/src/filesystem/std-dir.cc
@@ -61,7 +61,9 @@ struct fs::_Dir : _Dir_base
{
if (const auto entp = _Dir_base::advance(skip_permission_denied, ec))
{
- entry = fs::directory_entry{path / entp->d_name, get_file_type(*entp)};
+ auto name = path;
+ name /= entp->d_name;
+ entry = fs::directory_entry{name, get_file_type(*entp)};
return true;
}
else if (!ec)