diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-07-14 10:39:52 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2016-07-14 21:53:21 +0000 |
commit | af5daa6b5a147f1f62c499248cc70510c59934a6 (patch) | |
tree | 953f0c2f3039a84d51a23783ec5b6a395d8a3e90 /ui/qt/packet_list_model.cpp | |
parent | ee29efbd9ce5dbd894c7a7cd47c61f620fc37233 (diff) |
Qt: Replace a QMap with a QVector.
Use a vector to map packet numbers to their respective rows. This reduces
load times slightly here.
Change-Id: I80dc8656e1d0b6b1b7c75d33c001397b6221d25e
Reviewed-on: https://code.wireshark.org/review/16438
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/packet_list_model.cpp')
-rw-r--r-- | ui/qt/packet_list_model.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ui/qt/packet_list_model.cpp b/ui/qt/packet_list_model.cpp index 26116b6549..173da7be7c 100644 --- a/ui/qt/packet_list_model.cpp +++ b/ui/qt/packet_list_model.cpp @@ -53,6 +53,7 @@ PacketListModel::PacketListModel(QObject *parent, capture_file *cf) : QAbstractItemModel(parent), + number_to_row_(QVector<int>(0, -1)), max_row_height_(0), max_line_count_(1), idle_dissection_row_(0) @@ -104,7 +105,7 @@ guint PacketListModel::recreateVisibleRows() beginResetModel(); visible_rows_.clear(); - number_to_row_.clear(); + number_to_row_.fill(-1); endResetModel(); beginInsertRows(QModelIndex(), pos, pos); @@ -331,7 +332,7 @@ void PacketListModel::sort(int column, Qt::SortOrder order) beginResetModel(); visible_rows_.clear(); - number_to_row_.clear(); + number_to_row_.fill(-1); foreach (PacketListRecord *record, physical_rows_) { if (record->frameData()->flags.passed_dfilter || record->frameData()->flags.ref_time) { visible_rows_ << record; @@ -563,6 +564,9 @@ void PacketListModel::flushVisibleRows() gint pos = visible_rows_.count(); if (new_visible_rows_.count() > 0) { + if (number_to_row_.size() <= (int) cap_file_->count) { + number_to_row_.resize(cap_file_->count + 10000); // Arbitrary padding + } beginInsertRows(QModelIndex(), pos, pos + new_visible_rows_.count()); foreach (PacketListRecord *record, new_visible_rows_) { frame_data *fdata = record->frameData(); |