public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-4304] libstdc++: Add always_inline to trivial iterator operations
Date: Fri, 25 Nov 2022 15:07:39 +0000 (GMT)	[thread overview]
Message-ID: <20221125150739.32CC2384F89E@sourceware.org> (raw)

https://gcc.gnu.org/g:6bd8d119227ff9a4740739e91898258bcd854b9b

commit r13-4304-g6bd8d119227ff9a4740739e91898258bcd854b9b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Nov 24 21:13:36 2022 +0000

    libstdc++: Add always_inline to trivial iterator operations
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/stl_iterator_base_funcs.h (__distance):
            Add always_inline attribute to overload for random
            access iterators.
            (advance, distance, next, prev): Add always_inline attribute to
            inline functions that just forward to another function.

Diff:
---
 libstdc++-v3/include/bits/stl_iterator_base_funcs.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
index 1551b226ff4..25dddb3e7e8 100644
--- a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
+++ b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
@@ -94,6 +94,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
     }
 
   template<typename _RandomAccessIterator>
+    __attribute__((__always_inline__))
     inline _GLIBCXX14_CONSTEXPR
     typename iterator_traits<_RandomAccessIterator>::difference_type
     __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
@@ -141,7 +142,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
    *  and are constant time.  For other %iterator classes they are linear time.
   */
   template<typename _InputIterator>
-    _GLIBCXX_NODISCARD
+    _GLIBCXX_NODISCARD __attribute__((__always_inline__))
     inline _GLIBCXX17_CONSTEXPR
     typename iterator_traits<_InputIterator>::difference_type
     distance(_InputIterator __first, _InputIterator __last)
@@ -214,6 +215,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
    *  and are constant time.  For other %iterator classes they are linear time.
   */
   template<typename _InputIterator, typename _Distance>
+    __attribute__((__always_inline__))
     inline _GLIBCXX17_CONSTEXPR void
     advance(_InputIterator& __i, _Distance __n)
     {
@@ -225,7 +227,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
 #if __cplusplus >= 201103L
 
   template<typename _InputIterator>
-    _GLIBCXX_NODISCARD
+    _GLIBCXX_NODISCARD [[__gnu__::__always_inline__]]
     inline _GLIBCXX17_CONSTEXPR _InputIterator
     next(_InputIterator __x, typename
 	 iterator_traits<_InputIterator>::difference_type __n = 1)
@@ -237,7 +239,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
     }
 
   template<typename _BidirectionalIterator>
-    _GLIBCXX_NODISCARD
+    _GLIBCXX_NODISCARD [[__gnu__::__always_inline__]]
     inline _GLIBCXX17_CONSTEXPR _BidirectionalIterator
     prev(_BidirectionalIterator __x, typename
 	 iterator_traits<_BidirectionalIterator>::difference_type __n = 1)

                 reply	other threads:[~2022-11-25 15:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221125150739.32CC2384F89E@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).