forked from osmocom/wireshark
Optimize heuristic search by bubbling the matched element
The matched entry is bubbled to the head of the list for faster future search. Change-Id: I47375515f43387adbe0652556c03f0979a8dbe85 Reviewed-on: https://code.wireshark.org/review/37395 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
This commit is contained in:
parent
1f75d7b3b9
commit
5654dfd982
|
@ -2752,6 +2752,7 @@ dissector_try_heuristic(heur_dissector_list_t sub_dissectors, tvbuff_t *tvb,
|
|||
const char *saved_curr_proto;
|
||||
const char *saved_heur_list_name;
|
||||
GSList *entry;
|
||||
GSList *prev_entry = NULL;
|
||||
guint16 saved_can_desegment;
|
||||
guint saved_layers_len = 0;
|
||||
heur_dtbl_entry_t *hdtbl_entry;
|
||||
|
@ -2835,9 +2836,17 @@ dissector_try_heuristic(heur_dissector_list_t sub_dissectors, tvbuff_t *tvb,
|
|||
}
|
||||
if (len) {
|
||||
*heur_dtbl_entry = hdtbl_entry;
|
||||
|
||||
/* Bubble the matched entry to the top for faster search next time. */
|
||||
if (prev_entry != NULL) {
|
||||
prev_entry = g_slist_remove_link(prev_entry, entry);
|
||||
sub_dissectors->dissectors = g_slist_concat(entry, sub_dissectors->dissectors);
|
||||
}
|
||||
|
||||
status = TRUE;
|
||||
break;
|
||||
}
|
||||
prev_entry = entry;
|
||||
}
|
||||
|
||||
pinfo->current_proto = saved_curr_proto;
|
||||
|
|
Loading…
Reference in New Issue