From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 543E63858D1E; Tue, 29 Nov 2022 17:14:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 543E63858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669742058; bh=0dtLnmXSK1UaCErZ5js9LqSrTvbu1V6L+4LHjEv+TiU=; h=From:To:Subject:Date:From; b=WaBWtY48tpNYp5q7OyqN9Qz4WMw7ODxfq0Plgxlfke3YQ6dd01X2ZUNV+M5jsO1nz Pjit8jId71RXdPGhMcZKctrQ58ZyOTuOWPaWMvx3JVNw73Fk/dL/MB4yooExLow8BD 3zNgZTxmWLM3qLsvalCaSxuOEfI6IwP30rmcS1Yc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-4392] libstdc++: Remove unnecessary tag dispatching in std::vector X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 0ded30b361d2b1e43048b640e9ad6fef161fe9a9 X-Git-Newrev: 81cf0354d5f81f2c7600a3bc7ae4600757286995 Message-Id: <20221129171418.543E63858D1E@sourceware.org> Date: Tue, 29 Nov 2022 17:14:18 +0000 (GMT) List-Id: https://gcc.gnu.org/g:81cf0354d5f81f2c7600a3bc7ae4600757286995 commit r13-4392-g81cf0354d5f81f2c7600a3bc7ae4600757286995 Author: Jonathan Wakely Date: Tue Nov 29 15:19:33 2022 +0000 libstdc++: Remove unnecessary tag dispatching in std::vector There's no need to call a _M_xxx_dispatch function with a statically-known __false_type tag, we can just directly call the function that should be dispatched to. This will compile a tiny bit faster and save a function call with optimization or inlining turned off. Also add the always_inline attribute to the __iterator_category helper used for dispatching on the iterator category. libstdc++-v3/ChangeLog: * include/bits/stl_iterator_base_types.h (__iterator_category): Add always_inline attribute. * include/bits/stl_vector.h (assign(Iter, Iter)): Call _M_assign_aux directly, instead of _M_assign_dispatch. (insert(const_iterator, Iter, Iter)): Call _M_range_insert directly instead of _M_insert_dispatch. Diff: --- libstdc++-v3/include/bits/stl_iterator_base_types.h | 1 + libstdc++-v3/include/bits/stl_vector.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_iterator_base_types.h b/libstdc++-v3/include/bits/stl_iterator_base_types.h index 9eecd1dd855..5d90c0d8ea7 100644 --- a/libstdc++-v3/include/bits/stl_iterator_base_types.h +++ b/libstdc++-v3/include/bits/stl_iterator_base_types.h @@ -233,6 +233,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * sugar for internal library use only. */ template + __attribute__((__always_inline__)) inline _GLIBCXX_CONSTEXPR typename iterator_traits<_Iter>::iterator_category __iterator_category(const _Iter&) diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index b4ff3989a5d..e87fab0e51c 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -821,7 +821,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX20_CONSTEXPR void assign(_InputIterator __first, _InputIterator __last) - { _M_assign_dispatch(__first, __last, __false_type()); } + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } #else template void @@ -1478,8 +1478,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _InputIterator __last) { difference_type __offset = __position - cbegin(); - _M_insert_dispatch(begin() + __offset, - __first, __last, __false_type()); + _M_range_insert(begin() + __offset, __first, __last, + std::__iterator_category(__first)); return begin() + __offset; } #else