Remove xmethod_worker::clone

I think that the clone method of xmethod_worker can be removed.  It is
only used in find_overload_match, to clone an xmethod we want to
keep.  Instead, we can just std::move it out of the vector and into
value_from_xmethod.  value_from_xmethod creates a value that will own
the xmethod_worker from that point.  Other xmethod_workers left in the
vector will get destroyed when the vector gets destroyed, but the chosen
one will keep living inside the value struct.

gdb/ChangeLog:

	* extension.h (struct xmethod_worker) <clone>: Remove.
	* python/py-xmethods.c (struct python_xmethod_worker) <clone>:
	Remove.
	(python_xmethod_worker::clone): Remove.
	* valops.c (find_overload_match): Use std::move instead of
	clone.
This commit is contained in:
Simon Marchi
2018-01-07 09:25:33 -05:00
committed by Simon Marchi
parent ba18742c3a
commit f979c73fd0
4 changed files with 10 additions and 25 deletions

View File

@ -48,10 +48,6 @@ struct python_xmethod_worker : xmethod_worker
value *invoke (value *obj, value **args, int nargs) override;
/* Implementation of xmethod_worker::clone for Python. */
xmethod_worker_up clone () override;
/* Implementation of xmethod_worker::do_get_arg_types for Python. */
ext_lang_rc do_get_arg_types (int *nargs, type ***arg_types) override;
@ -80,19 +76,6 @@ python_xmethod_worker::~python_xmethod_worker ()
Py_DECREF (m_this_type);
}
/* See declaration. */
xmethod_worker_up
python_xmethod_worker::clone ()
{
/* We don't do much here, but we still need the GIL. */
gdbpy_enter enter_py (get_current_arch (), current_language);
xmethod_worker *worker = new python_xmethod_worker (m_py_worker, m_this_type);
return xmethod_worker_up (worker);
}
/* Invoke the "match" method of the MATCHER and return a new reference
to the result. Returns NULL on error. */