From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Add always_inline to trivial iterator operations
Date: Fri, 25 Nov 2022 15:08:04 +0000 [thread overview]
Message-ID: <20221125150804.128740-1-jwakely@redhat.com> (raw)
Tested x86_64-linux. Pushed to trunk.
-- >8 --
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.
---
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)
--
2.38.1
reply other threads:[~2022-11-25 15:08 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=20221125150804.128740-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@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).