diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-07-15 09:53:19 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2016-07-15 19:34:39 +0000 |
commit | 29cecf27c438cb2a1203ee5d877cb38566c977ee (patch) | |
tree | 7e495847ce7b1977e85efeef7f3d332d1cc92161 /ui/qt/packet_list_model.cpp | |
parent | d0af229d1fb59154af61a23913abceed161f2282 (diff) | |
download | wireshark-29cecf27c438cb2a1203ee5d877cb38566c977ee.tar.gz |
Qt: Reserve packet list model vectors.
Preallocate and hold onto the data in the various packet list model
vectors. I'm not sure how much this will affect performance, but the
documentation suggests that it's the right thing to do in our case.
Change-Id: If2d5ad142bf2d61e0bc2302990bd288274447df5
Reviewed-on: https://code.wireshark.org/review/16475
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 | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/ui/qt/packet_list_model.cpp b/ui/qt/packet_list_model.cpp index 173da7be7c..7ce670d60f 100644 --- a/ui/qt/packet_list_model.cpp +++ b/ui/qt/packet_list_model.cpp @@ -51,6 +51,8 @@ #include <wsutil/time_util.h> #endif +static const int reserved_packets_ = 100000; + PacketListModel::PacketListModel(QObject *parent, capture_file *cf) : QAbstractItemModel(parent), number_to_row_(QVector<int>(0, -1)), @@ -60,6 +62,12 @@ PacketListModel::PacketListModel(QObject *parent, capture_file *cf) : { setCaptureFile(cf); PacketListRecord::clearStringPool(); + + physical_rows_.reserve(reserved_packets_); + visible_rows_.reserve(reserved_packets_); + new_visible_rows_.reserve(1000); + number_to_row_.reserve(reserved_packets_); + connect(this, SIGNAL(maxLineCountChanged(QModelIndex)), this, SLOT(emitItemHeightChanged(QModelIndex)), Qt::QueuedConnection); @@ -104,7 +112,7 @@ guint PacketListModel::recreateVisibleRows() int pos = visible_rows_.count(); beginResetModel(); - visible_rows_.clear(); + visible_rows_.resize(0); number_to_row_.fill(-1); endResetModel(); @@ -123,10 +131,10 @@ guint PacketListModel::recreateVisibleRows() void PacketListModel::clear() { beginResetModel(); qDeleteAll(physical_rows_); - physical_rows_.clear(); - visible_rows_.clear(); - new_visible_rows_.clear(); - number_to_row_.clear(); + physical_rows_.resize(0); + visible_rows_.resize(0); + new_visible_rows_.resize(0); + number_to_row_.resize(0); PacketListRecord::clearStringPool(); endResetModel(); max_row_height_ = 0; @@ -331,7 +339,7 @@ void PacketListModel::sort(int column, Qt::SortOrder order) std::sort(physical_rows_.begin(), physical_rows_.end(), recordLessThan); beginResetModel(); - visible_rows_.clear(); + visible_rows_.resize(0); number_to_row_.fill(-1); foreach (PacketListRecord *record, physical_rows_) { if (record->frameData()->flags.passed_dfilter || record->frameData()->flags.ref_time) { @@ -575,7 +583,7 @@ void PacketListModel::flushVisibleRows() number_to_row_[fdata->num] = visible_rows_.count() - 1; } endInsertRows(); - new_visible_rows_.clear(); + new_visible_rows_.resize(0); } } |