[libcxx-commits] [libcxx] [libc++] Define deque::__block_size as an inline function (PR #89422)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 31 08:09:41 PDT 2024
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/89422
>From 9f9e5b47a0bbefe7ab34b5414f960b5b17a2e526 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 31 Jul 2024 11:08:47 -0400
Subject: [PATCH] [libc++] Define deque::__block_size inline
We noticed that __block_size was sometimes generating weak-defs that
were exported from programs. This is clearly unintended and unnecessary.
Defining the constant inline should allow it to be inlined in the code
all the time, which should help with that. It also simplifies the code.
---
libcxx/include/deque | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/libcxx/include/deque b/libcxx/include/deque
index 759de5d3a030a..93c1759e5eda2 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -276,7 +276,7 @@ private:
__map_iterator __m_iter_;
pointer __ptr_;
- static const difference_type __block_size;
+ static const difference_type __block_size = __deque_block_size<_ValueType, _DiffType>::value;
public:
typedef _ValueType value_type;
@@ -462,10 +462,6 @@ public:
}
};
-template <class _ValueType, class _Pointer, class _Reference, class _MapPointer, class _DiffType, _DiffType _BlockSize>
-const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>::__block_size =
- __deque_block_size<_ValueType, _DiffType>::value;
-
template <class _Tp, class _Allocator /*= allocator<_Tp>*/>
class _LIBCPP_TEMPLATE_VIS deque {
public:
@@ -578,7 +574,7 @@ private:
deque* const __base_;
};
- static const difference_type __block_size;
+ static const difference_type __block_size = __deque_block_size<value_type, difference_type>::value;
__map __map_;
size_type __start_;
@@ -1225,10 +1221,6 @@ private:
_LIBCPP_HIDE_FROM_ABI void __move_assign(deque& __c, false_type);
};
-template <class _Tp, class _Alloc>
-_LIBCPP_CONSTEXPR const typename allocator_traits<_Alloc>::difference_type deque<_Tp, _Alloc>::__block_size =
- __deque_block_size<value_type, difference_type>::value;
-
#if _LIBCPP_STD_VER >= 17
template <class _InputIterator,
class _Alloc = allocator<__iter_value_type<_InputIterator>>,
More information about the libcxx-commits
mailing list