public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101923] std::function's move ctor is slower than the copy one for empty source objects Date: Tue, 12 Oct 2021 10:59:24 +0000 [thread overview] Message-ID: <bug-101923-4-FxuP3ijHgV@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-101923-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101923 --- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:73b0f810a17a5f529fc8342a2df31276d3538851 commit r11-9111-g73b0f810a17a5f529fc8342a2df31276d3538851 Author: Jonathan Wakely <jwakely@redhat.com> Date: Tue Aug 17 11:30:56 2021 +0100 libstdc++: Optimize std::function move constructor [PR101923] PR 101923 points out that the unconditional swap in the std::function move constructor makes it slower than copying an empty std::function. The copy constructor has to check for the empty case before doing anything, and that makes it very fast for the empty case. Adding the same check to the move constructor avoids copying the _Any_data POD when we don't need to. We can also inline the effects of swap, by copying each member and then zeroing the pointer members. This makes moving an empty object at least as fast as copying an empty object. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/101923 * include/bits/std_function.h (function(function&&)): Check for non-empty parameter before doing any work. (cherry picked from commit 0808b0df9c4d31f4c362b9c85fb538b6aafcb517)
next prev parent reply other threads:[~2021-10-12 10:59 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-15 13:17 [Bug libstdc++/101923] New: " dartdart26 at gmail dot com 2021-08-15 13:38 ` [Bug libstdc++/101923] " dartdart26 at gmail dot com 2021-08-15 17:54 ` nok.raven at gmail dot com 2021-08-16 7:18 ` dartdart26 at gmail dot com 2021-08-16 7:30 ` [Bug tree-optimization/101923] " pinskia at gcc dot gnu.org 2021-08-17 6:09 ` dartdart26 at gmail dot com 2021-08-17 10:00 ` redi at gcc dot gnu.org 2021-08-17 10:25 ` redi at gcc dot gnu.org 2021-08-17 13:24 ` cvs-commit at gcc dot gnu.org 2021-08-18 6:02 ` dartdart26 at gmail dot com 2021-10-12 10:59 ` cvs-commit at gcc dot gnu.org [this message] 2022-12-29 22:14 ` pinskia at gcc dot gnu.org
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=bug-101923-4-FxuP3ijHgV@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).