From f6be5d6ee31b76838e242704782938bc9745659c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Dumont?= Date: Thu, 4 Feb 2021 06:45:18 +0100 Subject: [PATCH] libstdc++: Remove execution branch in deque iterator operator- libstdc++-v3/ChangeLog: * include/bits/stl_deque.h (std::operator-(deque::iterator, deque::iterator)): Replace if/then with a null pointer test. --- libstdc++-v3/include/bits/stl_deque.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index 04b70b77621..8bba7a3740f 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -352,12 +352,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER friend difference_type operator-(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT { - if (__builtin_expect(__x._M_node || __y._M_node, true)) - return difference_type(_S_buffer_size()) - * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first) - + (__y._M_last - __y._M_cur); - - return 0; + return difference_type(_S_buffer_size()) + * (__x._M_node - __y._M_node - int(__x._M_node != 0)) + + (__x._M_cur - __x._M_first) + + (__y._M_last - __y._M_cur); } // _GLIBCXX_RESOLVE_LIB_DEFECTS @@ -369,12 +367,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER operator-(const _Self& __x, const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT { - if (__builtin_expect(__x._M_node || __y._M_node, true)) - return difference_type(_S_buffer_size()) - * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first) - + (__y._M_last - __y._M_cur); - - return 0; + return difference_type(_S_buffer_size()) + * (__x._M_node - __y._M_node - int(__x._M_node != 0)) + + (__x._M_cur - __x._M_first) + + (__y._M_last - __y._M_cur); } friend _Self -- 2.30.2