]> gcc.gnu.org Git - gcc.git/commitdiff
* src/filesystem/path.cc (path::compare): Do not copy strings.
authorJonathan Wakely <jwakely@redhat.com>
Fri, 1 May 2015 20:05:42 +0000 (21:05 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 1 May 2015 20:05:42 +0000 (21:05 +0100)
From-SVN: r222704

libstdc++-v3/ChangeLog
libstdc++-v3/src/filesystem/path.cc

index 7e0700571058c67673bd01e850f66328cd76c331..a955a0f506d3e436e57079a39055c06d1621580d 100644 (file)
@@ -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.
index cc5780f1e145bc1978a48cf308da429e7a6300c8..7924732e646c1b2753a94bf5d7229a9aa02848ef 100644 (file)
@@ -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
This page took 0.066109 seconds and 5 git commands to generate.