[libcxx-commits] [libcxx] [libc++] Avoid including <ostream> in <fstream> and <strstream> (PR #116014)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 13 02:00:52 PST 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/116014

This reduces the include time of `<fstream>` from ~800ms to ~500ms.


>From 465a81b7502d3489325a17564b74ae4671290108 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Wed, 13 Nov 2024 11:00:01 +0100
Subject: [PATCH] [libc++] Avoid including <ostream> in <fstream> and
 <strstream>

---
 libcxx/include/fstream   | 2 +-
 libcxx/include/strstream | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index e3b9abbbdcf056..6913b70fc2444b 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -193,6 +193,7 @@ typedef basic_fstream<wchar_t> wfstream;
 #include <__fwd/fstream.h>
 #include <__locale>
 #include <__memory/addressof.h>
+#include <__ostream/basic_ostream.h>
 #include <__type_traits/enable_if.h>
 #include <__type_traits/is_same.h>
 #include <__utility/move.h>
@@ -200,7 +201,6 @@ typedef basic_fstream<wchar_t> wfstream;
 #include <__utility/unreachable.h>
 #include <cstdio>
 #include <istream>
-#include <ostream>
 #include <typeinfo>
 #include <version>
 
diff --git a/libcxx/include/strstream b/libcxx/include/strstream
index 9ff4024a7c7e21..11f36719b3ac03 100644
--- a/libcxx/include/strstream
+++ b/libcxx/include/strstream
@@ -130,8 +130,8 @@ private:
 */
 
 #include <__config>
+#include <__ostream/basic_ostream.h>
 #include <istream>
-#include <ostream>
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)



More information about the libcxx-commits mailing list