aboutsummaryrefslogtreecommitdiffstats
path: root/epan/packet.c
diff options
context:
space:
mode:
authorPhan Duc Nhat Minh <phanducnhatminh@gmail.com>2020-06-25 11:30:22 +0800
committerMartin Mathieson <martin.r.mathieson@googlemail.com>2020-06-25 17:17:20 +0000
commit5654dfd982ea3b790368630afb8b0af4eba2e30c (patch)
treefe981d98a633770afb22c700e7f0122903e5ff8b /epan/packet.c
parent1f75d7b3b9fa5d489d0d4816fe7dd491d5a617d7 (diff)
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>
Diffstat (limited to 'epan/packet.c')
-rw-r--r--epan/packet.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/epan/packet.c b/epan/packet.c
index be85cbb3b8..aeb55aa377 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -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;