[libcxx-commits] [PATCH] D99307: [libc++] Eliminate <compare>'s dependency on <array>

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 24 16:39:12 PDT 2021


Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, cjdb, zoecarver, libc++.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: libcxx-commits, sstefan1.
Herald added 1 blocking reviewer(s): libc++.

This refactor is not only a good idea, but is in fact required by the standard, in the sense that <array> is mandated to include <compare>. So <compare> shouldn't have a circular dependency on <array>!

According to "graph_header_deps.py", this also removes <compare>'s dependencies on everything-except-type-traits, and drops its cumulative cost from ~40KLOC to ~8KLOC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99307

Files:
  libcxx/include/compare


Index: libcxx/include/compare
===================================================================
--- libcxx/include/compare
+++ libcxx/include/compare
@@ -126,7 +126,6 @@
 
 #include <__config>
 #include <type_traits>
-#include <array>
 
 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #pragma GCC system_header
@@ -701,8 +700,8 @@
 
 template <size_t _Size>
 constexpr _ClassifyCompCategory
-__compute_comp_type(array<_ClassifyCompCategory, _Size> __types) {
-  array<int, _CCC_Size> __seen = {};
+__compute_comp_type(_ClassifyCompCategory (&__types)[_Size]) {
+  int __seen[_CCC_Size] = {};
   for (auto __type : __types)
     ++__seen[__type];
   if (__seen[_None])
@@ -723,7 +722,7 @@
 template <class ..._Ts>
 constexpr auto __get_comp_type() {
   using _CCC = _ClassifyCompCategory;
-  constexpr array<_CCC, sizeof...(_Ts)> __type_kinds{{__comp_detail::__type_to_enum<_Ts>()...}};
+  constexpr _CCC __type_kinds[sizeof...(_Ts)] = { __comp_detail::__type_to_enum<_Ts>()... };
   constexpr _CCC _Cat = sizeof...(_Ts) == 0 ? _StrongOrd
       : __compute_comp_type(__type_kinds);
   if constexpr (_Cat == _None)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99307.333173.patch
Type: text/x-patch
Size: 1114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210324/0cf647d2/attachment.bin>


More information about the libcxx-commits mailing list