From: François Dumont Date: Thu, 4 Feb 2021 05:45:18 +0000 (+0100) Subject: libstdc++: Remove execution branch in deque iterator operator- X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f6be5d6ee31b76838e242704782938bc9745659c;p=gcc.git 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. --- 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