seed r129 - trunk/libseed
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r129 - trunk/libseed
- Date: Wed, 5 Nov 2008 12:34:54 +0000 (UTC)
Author: racarr
Date: Wed Nov 5 12:34:53 2008
New Revision: 129
URL: http://svn.gnome.org/viewvc/seed?rev=129&view=rev
Log:
Avoid regenerating native closures for the duration of a functions
lifetime. It's (comparatively) expensive.
Modified:
trunk/libseed/seed-closure.c
Modified: trunk/libseed/seed-closure.c
==============================================================================
--- trunk/libseed/seed-closure.c (original)
+++ trunk/libseed/seed-closure.c Wed Nov 5 12:34:53 2008
@@ -322,7 +322,13 @@
GIArgInfo * arg_info;
gint num_args, i;
SeedNativeClosure * privates;
+ JSObjectRef cached;
+ cached = (JSObjectRef)seed_value_get_property(function, "__seed_native_closure");
+ if (cached && JSValueIsObjectOfClass(eng->context, cached, seed_native_callback_class))
+ {
+ return (SeedNativeClosure *)JSObjectGetPrivate(cached);
+ }
num_args = g_callable_info_get_n_args(info);
return_type = g_callable_info_get_return_type(info);
@@ -352,6 +358,10 @@
get_ffi_type(return_type), arg_types);
ffi_prep_closure(closure, cif, seed_handle_closure, privates);
+ seed_value_set_property((JSObjectRef)function, "__seed_native_closure", (JSValueRef)JSObjectMake(eng->context,
+ seed_native_callback_class,
+ privates));
+
return privates;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]