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

--- Comment #18 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <ja...@gcc.gnu.org>:

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

commit r13-4564-gd081807d8d70e3e87eae41e1560e54d503f4d465
Author: Jason Merrill <ja...@redhat.com>
Date:   Tue Dec 6 09:51:51 2022 -0500

    c++: avoid initializer_list<string> [PR105838]

    When constructing a vector<string> from { "strings" }, first is built an
    initializer_list<string>, which is then copied into the strings in the
    vector.  But this is inefficient: better would be treat the { "strings" }
    as a range and construct the strings in the vector directly from the
    string-literals.  We can do this transformation for standard library
    classes because we know the design patterns they follow.

            PR c++/105838

    gcc/cp/ChangeLog:

            * call.cc (list_ctor_element_type): New.
            (braced_init_element_type): New.
            (has_non_trivial_temporaries): New.
            (maybe_init_list_as_array): New.
            (maybe_init_list_as_range): New.
            (build_user_type_conversion_1): Use maybe_init_list_as_range.
            * parser.cc (cp_parser_braced_list): Call
            recompute_constructor_flags.
            * cp-tree.h (find_temps_r): Declare.

    gcc/testsuite/ChangeLog:

            * g++.dg/tree-ssa/initlist-opt1.C: New test.

Reply via email to