GNOME Bugzilla – Bug 629247
add gsimpleasyncresult methods to take over a GError
Last modified: 2010-11-01 02:40:22 UTC
A common code pattern in gio is g_simple_async_result_new_from_error(..., error) g_error_free (error); and g_simple_async_result_set_from_error (result, error); g_error_free (error); This does an unnecessary copy of the GError, when it could just as well take over the caller's ownership. Attached patch adds g_simple_async_result_new_take_error() and g_simple_async_result_take_from_error() [not too sure about the naming on that one]. If it's accepted, I will provide a further patch that ports over instances of the above patterns in gio to the new functions.
Created attachment 169934 [details] [review] Add g_simple_async_result_new_take_error and ..._take_from_error This allows transferring ownership of the #GError, so there's no needless duplication. Bug #629247.
Sounds like a reasonable idea, and the patch looks fine. But we should probably hold it until 2.27, at this point.
So is this ok-to-commit now that 2-26 is branched off? :)
Also, about the naming: I used g_simple_async_result_take_from_error() in the patch, but maybe g_simple_async_result_take_error() is simpler and nicer?