aboutsummaryrefslogtreecommitdiffstats
path: root/epan/packet.c
diff options
context:
space:
mode:
authorTomasz Moń <desowin@gmail.com>2023-01-28 13:41:50 +0100
committerTomasz Moń <desowin@gmail.com>2023-01-28 15:17:42 +0100
commite7d5c49fe1dadfd6393539ba1b4d535087d79abe (patch)
treea60d83baefba3a9df0073c3d59375cb13112d9e1 /epan/packet.c
parent5e3d77761b4f813118382334d1b66defd846d5e7 (diff)
epan: Use hash table for dependent frames
Dependent frames list order does not matter and thus significantly faster data structure can be used. Replace the list with hash table to avoid excessive CPU usage when opening files containing reassembled packets consisting of large number of fragments.
Diffstat (limited to 'epan/packet.c')
-rw-r--r--epan/packet.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/epan/packet.c b/epan/packet.c
index 204e17696d..e69af8857e 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -452,13 +452,10 @@ mark_frame_as_depended_upon(frame_data *fd, guint32 frame_num)
/* ws_assert(frame_num < fd->num) - we assume in several other
* places in the code that frames don't depend on future
* frames. */
- /* XXX: Looking to see if the frame is already there is slow
- * if there's a lot of dependent frames, so this should
- * be a hash table or something.
- */
- if (g_slist_find(fd->dependent_frames, GUINT_TO_POINTER(frame_num)) == NULL) {
- fd->dependent_frames = g_slist_prepend(fd->dependent_frames, GUINT_TO_POINTER(frame_num));
+ if (fd->dependent_frames == NULL) {
+ fd->dependent_frames = g_hash_table_new(g_direct_hash, g_direct_equal);
}
+ g_hash_table_insert(fd->dependent_frames, GUINT_TO_POINTER(frame_num), NULL);
}
}