[libcxx-commits] [libcxx] ee22e25 - [libc++] Remove <array> include from <span> (#83742)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Mar 9 03:49:39 PST 2024


Author: Nikolas Klauser
Date: 2024-03-09T12:49:36+01:00
New Revision: ee22e255648ee9b056280484b4b70d4542bc807e

URL: https://github.com/llvm/llvm-project/commit/ee22e255648ee9b056280484b4b70d4542bc807e
DIFF: https://github.com/llvm/llvm-project/commit/ee22e255648ee9b056280484b4b70d4542bc807e.diff

LOG: [libc++] Remove <array> include from <span> (#83742)

This reduces the include time of `<span>` from 122ms to 78ms.

Added: 
    

Modified: 
    libcxx/include/__fwd/array.h
    libcxx/include/span
    libcxx/test/libcxx/transitive_includes/cxx23.csv
    libcxx/test/libcxx/transitive_includes/cxx26.csv
    libcxx/test/std/ranges/range.utility/range.subrange/operator.pair_like.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__fwd/array.h b/libcxx/include/__fwd/array.h
index ff3a3eeeefc71f..b429d0c5a95427 100644
--- a/libcxx/include/__fwd/array.h
+++ b/libcxx/include/__fwd/array.h
@@ -35,6 +35,12 @@ template <size_t _Ip, class _Tp, size_t _Size>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT;
 #endif
 
+template <class>
+struct __is_std_array : false_type {};
+
+template <class _Tp, size_t _Size>
+struct __is_std_array<array<_Tp, _Size> > : true_type {};
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___FWD_ARRAY_H

diff  --git a/libcxx/include/span b/libcxx/include/span
index cfeef35d2d80e9..c0fe25ddb4beb9 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -130,10 +130,12 @@ template<class R>
 
 #include <__assert>
 #include <__config>
+#include <__fwd/array.h>
 #include <__fwd/span.h>
 #include <__iterator/bounded_iter.h>
 #include <__iterator/concepts.h>
 #include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
 #include <__iterator/wrap_iter.h>
 #include <__memory/pointer_traits.h>
 #include <__ranges/concepts.h>
@@ -141,13 +143,16 @@ template<class R>
 #include <__ranges/enable_borrowed_range.h>
 #include <__ranges/enable_view.h>
 #include <__ranges/size.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_const.h>
 #include <__type_traits/is_convertible.h>
+#include <__type_traits/remove_cv.h>
 #include <__type_traits/remove_cvref.h>
 #include <__type_traits/remove_reference.h>
 #include <__type_traits/type_identity.h>
 #include <__utility/forward.h>
-#include <array>   // for array
-#include <cstddef> // for byte
+#include <cstddef>      // for byte
+#include <initializer_list>
 #include <stdexcept>
 #include <version>
 
@@ -171,12 +176,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER >= 20
 
-template <class _Tp>
-struct __is_std_array : false_type {};
-
-template <class _Tp, size_t _Sz>
-struct __is_std_array<array<_Tp, _Sz>> : true_type {};
-
 template <class _Tp>
 struct __is_std_span : false_type {};
 
@@ -586,6 +585,7 @@ _LIBCPP_END_NAMESPACE_STD
 _LIBCPP_POP_MACROS
 
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+#  include <array>
 #  include <concepts>
 #  include <functional>
 #  include <iterator>

diff  --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 64ff9261820a96..043d23d551c5cd 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -509,7 +509,6 @@ shared_mutex string
 shared_mutex version
 source_location cstdint
 source_location version
-span array
 span cstddef
 span initializer_list
 span limits

diff  --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index 64ff9261820a96..043d23d551c5cd 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -509,7 +509,6 @@ shared_mutex string
 shared_mutex version
 source_location cstdint
 source_location version
-span array
 span cstddef
 span initializer_list
 span limits

diff  --git a/libcxx/test/std/ranges/range.utility/range.subrange/operator.pair_like.pass.cpp b/libcxx/test/std/ranges/range.utility/range.subrange/operator.pair_like.pass.cpp
index 1d0dfd05b3f7e2..2641a9ad94ea76 100644
--- a/libcxx/test/std/ranges/range.utility/range.subrange/operator.pair_like.pass.cpp
+++ b/libcxx/test/std/ranges/range.utility/range.subrange/operator.pair_like.pass.cpp
@@ -13,6 +13,7 @@
 //   requires pair-like-convertible-from<PairLike, const I&, const S&>
 // constexpr operator PairLike() const;
 
+#include <array>
 #include <cassert>
 #include <concepts>
 #include <ranges>


        


More information about the libcxx-commits mailing list