diff options
author | Tom Tromey <tromey@adacore.com> | 2019-04-24 06:50:06 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-04-25 12:59:35 -0600 |
commit | 94aeb44b001ab2d632806242a3bacb0a879abe15 (patch) | |
tree | edff0a78beb11b19021e0679c1168e14c96bd84a /gdb/xml-support.c | |
parent | 680d7fd5fcff860a31021845389d4dfeb7b42e3c (diff) | |
download | gdb-94aeb44b001ab2d632806242a3bacb0a879abe15.zip gdb-94aeb44b001ab2d632806242a3bacb0a879abe15.tar.gz gdb-94aeb44b001ab2d632806242a3bacb0a879abe15.tar.bz2 |
Make exception handling more efficient
This makes exception handling more efficient in a few spots, through
the use of const- and rvalue-references.
I wrote this patch by commenting out the gdb_exception copy
constructor and then examining the resulting error messages one by
one, introducing the use of std::move where appropriate.
gdb/ChangeLog
2019-04-25 Tom Tromey <tromey@adacore.com>
* xml-support.c (struct gdb_xml_parser) <set_error>: Take an
rvalue reference.
(gdb_xml_start_element_wrapper, gdb_xml_end_element_wrapper)
(gdb_xml_parser::parse): Use std::move.
* python/python-internal.h (gdbpy_convert_exception): Take a const
reference.
* python/py-value.c (valpy_getitem, valpy_nonzero): Use
std::move.
* python/py-utils.c (gdbpy_convert_exception): Take a const
reference.
* python/py-inferior.c (infpy_write_memory, infpy_search_memory):
Use std::move.
* python/py-breakpoint.c (bppy_set_condition, bppy_set_commands):
Use std::move.
* mi/mi-main.c (mi_print_exception): Take a const reference.
* main.c (handle_command_errors): Take a const reference.
* linespec.c (parse_linespec): Use std::move.
* infcall.c (run_inferior_call): Use std::move.
(call_function_by_hand_dummy): Use std::move.
* exec.c (try_open_exec_file): Use std::move.
* exceptions.h (exception_print, exception_fprintf)
(exception_print_same): Update.
* exceptions.c (print_exception, exception_print)
(exception_fprintf, exception_print_same): Change parameters to
const reference.
* event-top.c (gdb_rl_callback_read_char_wrapper): Update.
* common/new-op.c: Use std::move.
* common/common-exceptions.h (struct gdb_exception): Add move
constructor.
(struct gdb_exception_error, struct gdb_exception_quit, struct
gdb_quit_bad_alloc): Change constructor to move constructor.
(throw_exception): Change parameter to rvalue reference.
* common/common-exceptions.c (throw_exception): Take rvalue
reference.
* cli/cli-interp.c (safe_execute_command): Use std::move.
* breakpoint.c (insert_bp_location, location_to_sals): Use
std::move.
Diffstat (limited to 'gdb/xml-support.c')
-rw-r--r-- | gdb/xml-support.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/gdb/xml-support.c b/gdb/xml-support.c index d4cd89c..ae727da 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -113,9 +113,9 @@ struct gdb_xml_parser { m_is_xinclude = is_xinclude; } /* A thrown error, if any. */ - void set_error (gdb_exception error) + void set_error (gdb_exception &&error) { - m_error = error; + m_error = std::move (error); #ifdef HAVE_XML_STOPPARSER XML_StopParser (m_expat_parser, XML_FALSE); #endif @@ -387,9 +387,9 @@ gdb_xml_start_element_wrapper (void *data, const XML_Char *name, { parser->start_element (name, attrs); } - catch (const gdb_exception &ex) + catch (gdb_exception &ex) { - parser->set_error (ex); + parser->set_error (std::move (ex)); } } @@ -459,9 +459,9 @@ gdb_xml_end_element_wrapper (void *data, const XML_Char *name) { parser->end_element (name); } - catch (const gdb_exception &ex) + catch (gdb_exception &ex) { - parser->set_error (ex); + parser->set_error (std::move (ex)); } } @@ -603,7 +603,7 @@ gdb_xml_parser::parse (const char *buffer) else { gdb_assert (m_error.reason < 0); - throw_exception (m_error); + throw_exception (std::move (m_error)); } if (m_last_line != 0) |