* [committed] libstdc++: Avoid including <algorithm> in <filesystem> [PR92546]
@ 2022-03-17 17:52 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-03-17 17:52 UTC (permalink / raw)
To: libstdc++, gcc-patches
Tested x86_64-linux, x86_64-mingw, pushed to trunk.
-- >8 --
This only affects Windows, but reduces the preprocessed size of
<filesystem> significantly.
libstdc++-v3/ChangeLog:
PR libstdc++/92546
* include/bits/fs_path.h (path::make_preferred): Use
handwritten loop instead of std::replace.
---
libstdc++-v3/include/bits/fs_path.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h
index b16a878f24b..9e06fa679d8 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -52,7 +52,6 @@
#if defined(_WIN32) && !defined(__CYGWIN__)
# define _GLIBCXX_FILESYSTEM_IS_WINDOWS 1
-# include <algorithm>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
@@ -1060,8 +1059,12 @@ namespace __detail
path::make_preferred()
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
- std::replace(_M_pathname.begin(), _M_pathname.end(), L'/',
- preferred_separator);
+ auto __pos = _M_pathname.find(L'/');
+ while (__pos != _M_pathname.npos)
+ {
+ _M_pathname[__pos] = preferred_separator;
+ __pos = _M_pathname.find(L'/', __pos);
+ }
#endif
return *this;
}
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-17 17:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-17 17:52 [committed] libstdc++: Avoid including <algorithm> in <filesystem> [PR92546] Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).