From cf6ea68018b94529aeb02aaa8b430c8d061e55c1 Mon Sep 17 00:00:00 2001 From: Garrett Regier Date: Wed, 3 Jun 2015 04:59:11 -0700 Subject: girepository: Add g_struct_info_find_field() Add find_field utility function for finding a field info by name. Beyond convenience, this should be faster than manually using the get_n_fields and get_field functions because get_field does an additional iteration for each field to calculate offsets O(n^2). Thus find_field combines the offset and comparison computations into a single loop O(n). Based on a patch by Simon Feltman. --- girepository/gistructinfo.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'girepository/gistructinfo.h') diff --git a/girepository/gistructinfo.h b/girepository/gistructinfo.h index 2651311d..4a60d5bb 100644 --- a/girepository/gistructinfo.h +++ b/girepository/gistructinfo.h @@ -48,6 +48,10 @@ GI_AVAILABLE_IN_ALL GIFieldInfo * g_struct_info_get_field (GIStructInfo *info, gint n); +GI_AVAILABLE_IN_ALL +GIFieldInfo * g_struct_info_find_field (GIStructInfo *info, + const gchar *name); + GI_AVAILABLE_IN_ALL gint g_struct_info_get_n_methods (GIStructInfo *info); -- cgit v1.2.1