Use proto_get_finfo_ptr_array() rather than proto_find_finfo().

As the comments say, proto_find_finfo() is slower than
proto_get_finfo_ptr_array(), as it has to scan the entire tree, and,
given that we're priming the tree with the fields we need (which we
*have* to do to *guarantee* that we'll get the fields we want;
requesting that a protocol tree be constructed isn't sufficient, and
asking for a "visible" protocol tree is overkill),
proto_get_finfo_ptr_array() will work.

Change-Id: Ic1e21105a0a89003a3cdd3d7a2e55ac287ddad5e
Reviewed-on: https://code.wireshark.org/review/21068
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2017-04-12 17:09:39 -07:00
parent 37e45ccba8
commit 9769e8af99
1 changed files with 4 additions and 12 deletions

View File

@ -43,7 +43,7 @@ int extract_uint(proto_tree *tree, int field_id, guint32 *result_array, size_t *
return -1;
}
finfo_array = proto_find_finfo(tree, field_id);
finfo_array = proto_get_finfo_ptr_array(tree, field_id);
if (finfo_array == NULL) {
return -1;
@ -56,8 +56,6 @@ int extract_uint(proto_tree *tree, int field_id, guint32 *result_array, size_t *
result_array[i] = fvalue_get_uinteger(&((field_info*)finfo_array->pdata[i])->value);
}
g_ptr_array_free(finfo_array, TRUE);
return 0;
}
@ -70,7 +68,7 @@ int extract_ui64(proto_tree *tree, int field_id, guint64 *result_array, size_t *
return -1;
}
finfo_array = proto_find_finfo(tree, field_id);
finfo_array = proto_get_finfo_ptr_array(tree, field_id);
if (finfo_array == NULL) {
return -1;
@ -83,8 +81,6 @@ int extract_ui64(proto_tree *tree, int field_id, guint64 *result_array, size_t *
result_array[i] = fvalue_get_uinteger64(&((field_info*)finfo_array->pdata[i])->value);
}
g_ptr_array_free(finfo_array, TRUE);
return 0;
}
@ -97,7 +93,7 @@ int extract_si64(proto_tree *tree, int field_id, guint64 *result_array, size_t *
return -1;
}
finfo_array = proto_find_finfo(tree, field_id);
finfo_array = proto_get_finfo_ptr_array(tree, field_id);
if (finfo_array == NULL) {
return -1;
@ -110,8 +106,6 @@ int extract_si64(proto_tree *tree, int field_id, guint64 *result_array, size_t *
result_array[i] = fvalue_get_sinteger64(&((field_info*)finfo_array->pdata[i])->value);
}
g_ptr_array_free(finfo_array, TRUE);
return 0;
}
@ -124,7 +118,7 @@ int extract_bool(proto_tree *tree, int field_id, gboolean *result_array, size_t
return -1;
}
finfo_array = proto_find_finfo(tree, field_id);
finfo_array = proto_get_finfo_ptr_array(tree, field_id);
if (finfo_array == NULL) {
return -1;
@ -142,8 +136,6 @@ int extract_bool(proto_tree *tree, int field_id, gboolean *result_array, size_t
result_array[i] = FALSE;
}
g_ptr_array_free(finfo_array, TRUE);
return 0;
}