public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-7157] libstdc++: Remove execution branch in deque iterator operator-
@ 2021-02-09 20:56 Franथईois Dumont
  0 siblings, 0 replies; only message in thread
From: Franथईois Dumont @ 2021-02-09 20:56 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:f6be5d6ee31b76838e242704782938bc9745659c

commit r11-7157-gf6be5d6ee31b76838e242704782938bc9745659c
Author: François Dumont <fdumont@gcc.gnu.org>
Date:   Thu Feb 4 06:45:18 2021 +0100

    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:
---
 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-09 20:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 20:56 [gcc r11-7157] libstdc++: Remove execution branch in deque iterator operator- Franथईois Dumont

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).