public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Add always_inline to trivial iterator operations
@ 2022-11-25 15:08 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-11-25 15:08 UTC (permalink / raw)
  To: libstdc++, gcc-patches

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


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

only message in thread, other threads:[~2022-11-25 15:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 15:08 [committed] libstdc++: Add always_inline to trivial iterator operations Jonathan Wakely

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).