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 | |
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')
-rw-r--r-- | ui/qt/packet_list_model.cpp | 8 | ||||
-rw-r--r-- | ui/qt/packet_list_model.h | 2 |
2 files changed, 7 insertions, 3 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(); diff --git a/ui/qt/packet_list_model.h b/ui/qt/packet_list_model.h index 7d67eb3a3d..40360f5552 100644 --- a/ui/qt/packet_list_model.h +++ b/ui/qt/packet_list_model.h @@ -98,7 +98,7 @@ private: QVector<PacketListRecord *> physical_rows_; QVector<PacketListRecord *> visible_rows_; QVector<PacketListRecord *> new_visible_rows_; - QMap<int, int> number_to_row_; + QVector<int> number_to_row_; int max_row_height_; // px int max_line_count_; |