[Mono-dev] [PATCH] Extract mono_exception_get_message_string from mono_print_exception
Michael Hutchinson
m.j.hutchinson at gmail.com
Fri Jul 2 16:34:05 EDT 2010
On Fri, Jul 2, 2010 at 3:43 PM, Robert Jordan <robertj at gmx.net> wrote:
>
> You can get rid of the loop and optimize it further by caching
> System.Object's ToString method:
>
> MonoString *
> mono_object_to_string (MonoObject *obj, MonoObject **exc)
> {
> static MonoMethod *to_string = NULL;
> MonoMethod *method;
>
> g_assert (obj);
>
> if (!to_string)
> to_string = mono_class_get_method_from_name_flags
> (mono_get_object_class (), "ToString", 0, METHOD_ATTRIBUTE_VIRTUAL |
> METHOD_ATTRIBUTE_PUBLIC);
>
> method = mono_object_get_virtual_method (obj, method);
>
> return (MonoString *) mono_runtime_invoke (method, obj, NULL, exc);
> }
Makes sense - I'm not familiar with Mono runtime API, and I'd just
lifted code directly from mono_print_exception.
I've folded this into my patch (with the to_string fix), added
Changelogs, and updated the utils Makefile.am to install mono-error.h.
OK to commit now?
--
Michael Hutchinson
http://mjhutchinson.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mono-print-exception.diff
Type: application/octet-stream
Size: 6640 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100702/ecd63e8d/attachment.obj
More information about the Mono-devel-list
mailing list