mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-20 01:25:03 +08:00
cfb582f627
GCC does not do a good job of optimizing the table of function pointers used for variant visitation. This avoids using the table for the common case of visiting a single variant with a small number of alternative types. Instead we use: switch(v.index()) { case 0: return visitor(get<0>(v)); case 1: return visitor(get<1>(v)); ... } It's not quite that simple, because get<1>(v) is ill-formed if the variant only has one alternative, and similarly for each get<N>. We need to ensure each case only applies the visitor if the index is in range for the actual type we're dealing with, and tell the compiler that the case is unreachable otherwise. We also need to invoke the visitor via the __gen_vtable_impl::__visit_invoke function, to handle the raw visitation cases used to implement std::variant assignments and comparisons. Because that gets quite verbose and repetitive, a macro is used to stamp out the cases. We also need to handle the valueless_by_exception case, but only for raw visitation, because std::visit already checks for it before calling __do_visit. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/78113 * include/std/variant (__do_visit): Use a switch when we have a single variant with a small number of alternatives. |
||
---|---|---|
.. | ||
config | ||
doc | ||
include | ||
libsupc++ | ||
po | ||
python | ||
scripts | ||
src | ||
testsuite | ||
acinclude.m4 | ||
aclocal.m4 | ||
ChangeLog | ||
ChangeLog-1998 | ||
ChangeLog-1999 | ||
ChangeLog-2000 | ||
ChangeLog-2001 | ||
ChangeLog-2002 | ||
ChangeLog-2003 | ||
ChangeLog-2004 | ||
ChangeLog-2005 | ||
ChangeLog-2006 | ||
ChangeLog-2007 | ||
ChangeLog-2008 | ||
ChangeLog-2009 | ||
ChangeLog-2010 | ||
ChangeLog-2011 | ||
ChangeLog-2012 | ||
ChangeLog-2013 | ||
ChangeLog-2014 | ||
ChangeLog-2015 | ||
ChangeLog-2016 | ||
ChangeLog-2017 | ||
ChangeLog-2018 | ||
ChangeLog-2019 | ||
ChangeLog-2020 | ||
config.h.in | ||
configure | ||
configure.ac | ||
configure.host | ||
crossconfig.m4 | ||
fragment.am | ||
linkage.m4 | ||
Makefile.am | ||
Makefile.in | ||
README |
file: libstdc++-v3/README New users may wish to point their web browsers to the file index.html in the 'doc/html' subdirectory. It contains brief building instructions and notes on how to configure the library in interesting ways.