summaryrefslogtreecommitdiff
path: root/gi/pygi-array.c
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2014-02-07 20:16:21 -0800
committerSimon Feltman <sfeltman@src.gnome.org>2014-03-03 05:28:27 -0800
commit5798f94b6a727b930b07fe840b0aef264f98a80e (patch)
treefa0b0636c6d1ac9b2992bb0e32bf93be4b9ade3e /gi/pygi-array.c
parentad680ae9c37a0091628a7d66010fbf70aa1a2e43 (diff)
downloadpygobject-5798f94b6a727b930b07fe840b0aef264f98a80e.tar.gz
Use ffi_call directly instead of g_callable_info_invoke
Cleanup internal callable cache and state tracking by removing multiple counting schemes for differently sized "in" and "out" argument arrays. Use a single count based on the total number of arguments passed to C (inclusive of instance argument and GError exception where applicable). Size all state tracking arrays to the same size and ensure argument cache indices always line up with these arrays. This cleans up logic which was required by g_callable_info_invoke for splitting "in" and "out" arguments up. Cleanup array marshaling which can now rely on the new scheme which ensures the "arg_values" array always points to the correct location for length argument values. Cache the ffi_cif struct in PyGICallableCache via GIFunctionInvoker and related GI methods. Overall, these changes can give a performance boost of almost 2x for simple function calls (see ticket for micro benchmarks). https://bugzilla.gnome.org/show_bug.cgi?id=723642
Diffstat (limited to 'gi/pygi-array.c')
-rw-r--r--gi/pygi-array.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/gi/pygi-array.c b/gi/pygi-array.c
index a50c1815..c17ace0e 100644
--- a/gi/pygi-array.c
+++ b/gi/pygi-array.c
@@ -370,24 +370,10 @@ array_success:
PyGIArgCache *child_cache =
_pygi_callable_cache_get_arg (callable_cache, array_cache->len_arg_index);
- if (child_cache->direction == PYGI_DIRECTION_BIDIRECTIONAL) {
- gint *len_arg = (gint *)state->in_args[child_cache->c_arg_index].v_pointer;
- /* if we are not setup yet just set the in arg */
- if (len_arg == NULL) {
- if (!gi_argument_from_py_ssize_t (&state->in_args[child_cache->c_arg_index],
- length,
- child_cache->type_tag)) {
- goto err;
- }
- } else {
- *len_arg = length;
- }
- } else {
- if (!gi_argument_from_py_ssize_t (&state->in_args[child_cache->c_arg_index],
- length,
- child_cache->type_tag)) {
- goto err;
- }
+ if (!gi_argument_from_py_ssize_t (&state->arg_values[child_cache->c_arg_index],
+ length,
+ child_cache->type_tag)) {
+ goto err;
}
}
@@ -528,7 +514,7 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
len = g_strv_length ((gchar **)arg->v_pointer);
}
} else {
- GIArgument *len_arg = state->args[array_cache->len_arg_index];
+ GIArgument *len_arg = &state->arg_values[array_cache->len_arg_index];
PyGIArgCache *arg_cache = _pygi_callable_cache_get_arg (callable_cache,
array_cache->len_arg_index);
@@ -684,7 +670,7 @@ _wrap_c_array (PyGIInvokeState *state,
} else if (array_cache->is_zero_terminated) {
len = g_strv_length ((gchar **)data);
} else if (array_cache->len_arg_index >= 0) {
- GIArgument *len_arg = state->args[array_cache->len_arg_index];
+ GIArgument *len_arg = &state->arg_values[array_cache->len_arg_index];
len = len_arg->v_long;
}