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 libstdc++/103755] {has,use}_facet() and iostream constructor performance
Date: Fri, 11 Nov 2022 05:29:45 +0000	[thread overview]
Message-ID: <bug-103755-4-T0unaY3lDr@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103755-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103755

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:b3ac43a3c05744d62a963d656bed782fc867ad79

commit r13-3888-gb3ac43a3c05744d62a963d656bed782fc867ad79
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Nov 9 21:44:31 2022 +0000

    libstdc++: Avoid redundant checks in std::use_facet [PR103755]

    We do not need to do bounds checks or a runtime dynamic_cast when using
    std::has_facet and std::use_facet to access the default facets that are
    guaranteed to be present in every std::locale object. We can just index
    straight into the array and use a static_cast for the conversion.

    This patch adds a new std::__try_use_facet function that is like
    std::use_facet but returns a pointer, so can be used to implement both
    std::has_facet and std::use_facet. We can then do the necessary
    metaprogramming to skip the redundant checks in std::__try_use_facet.

    To avoid having to export (or hide) instantiations of the new function
    from libstdc++.so the instantiations are given hidden visibility. This
    allows them to be used in the library, but user code will instantiate it
    again using the definition in the header. That would happen anyway,
    because there are no explicit instantiation declarations for any of
    std::has_facet, std::use_facet, or the new std::__try_use_facet.

    libstdc++-v3/ChangeLog:

            PR libstdc++/103755
            * config/abi/pre/gnu.ver: Tighten patterns for facets in the
            base version. Add exports for __try_use_facet.
            * include/bits/basic_ios.tcc (basic_ios::_M_cache_locale): Use
            __try_use_facet instead of has_facet and use_facet.
            * include/bits/fstream.tcc (basic_filebuf::basic_filebuf()):
            Likewise.
            (basic_filebuf::imbue): Likewise.
            * include/bits/locale_classes.h (locale, locale::id)
            (locale::_Impl): Declare __try_use_facet as a friend.
            * include/bits/locale_classes.tcc (__try_use_facet): Define new
            function template with special cases for default facets.
            (has_facet, use_facet): Call __try_use_facet.
            * include/bits/locale_facets.tcc (__try_use_facet): Declare
            explicit instantiations.
            * include/bits/locale_facets_nonio.tcc (__try_use_facet):
            Likewise.
            * src/c++11/locale-inst-monetary.h (INSTANTIATE_FACET_ACCESSORS):
            Use new macro for facet accessor instantiations.
            * src/c++11/locale-inst-numeric.h (INSTANTIATE_FACET_ACCESSORS):
            Likewise.
            * src/c++11/locale-inst.cc (INSTANTIATE_USE_FACET): Define new
            macro for instantiating __try_use_facet and use_facet.
            (INSTANTIATE_FACET_ACCESSORS): Define new macro for also
            defining has_facet.
            * src/c++98/compatibility-ldbl.cc (__try_use_facet):
            Instantiate.
            * testsuite/22_locale/ctype/is/string/89728_neg.cc: Adjust
            expected errors.

  parent reply	other threads:[~2022-11-11  5:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17  3:49 [Bug libstdc++/103755] New: " dprokoptsev at gmail dot com
2021-12-17 10:31 ` [Bug libstdc++/103755] " redi at gcc dot gnu.org
2021-12-17 17:22 ` redi at gcc dot gnu.org
2021-12-17 17:52 ` redi at gcc dot gnu.org
2021-12-17 21:05 ` redi at gcc dot gnu.org
2021-12-19  3:41 ` dprokoptsev at gmail dot com
2021-12-19  3:44 ` dprokoptsev at gmail dot com
2021-12-19 13:04 ` redi at gcc dot gnu.org
2022-02-03 17:06 ` redi at gcc dot gnu.org
2022-09-23 12:57 ` redi at gcc dot gnu.org
2022-11-11  5:29 ` cvs-commit at gcc dot gnu.org [this message]
2022-11-11 13:27 ` redi at gcc dot gnu.org
2022-11-11 21:54 ` seurer at gcc dot gnu.org
2022-11-11 21:55 ` redi at gcc dot gnu.org
2022-11-11 22:39 ` redi at gcc dot gnu.org
2022-11-12  1:30 ` cvs-commit at gcc dot gnu.org
2022-11-12  2:00 ` redi at gcc dot gnu.org
2023-01-06 12:12 ` redi at gcc dot gnu.org
2023-01-11 14:07 ` redi at gcc dot gnu.org
2023-04-21 15:01 ` cvs-commit at gcc dot gnu.org
2023-04-21 15:06 ` redi 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-103755-4-T0unaY3lDr@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: 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).