mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 22:18:05 -06:00
Reserve space before appending elements
This commit is contained in:
committed by
sledgehammer999
parent
3970d91d19
commit
0758109d15
@@ -632,9 +632,12 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
|
|
||||||
void TransferListModel::addTorrents(const QVector<BitTorrent::Torrent *> &torrents)
|
void TransferListModel::addTorrents(const QVector<BitTorrent::Torrent *> &torrents)
|
||||||
{
|
{
|
||||||
int row = m_torrentList.size();
|
qsizetype row = m_torrentList.size();
|
||||||
beginInsertRows({}, row, (row + torrents.size()));
|
const qsizetype total = row + torrents.size();
|
||||||
|
|
||||||
|
beginInsertRows({}, row, total);
|
||||||
|
|
||||||
|
m_torrentList.reserve(total);
|
||||||
for (BitTorrent::Torrent *torrent : torrents)
|
for (BitTorrent::Torrent *torrent : torrents)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!m_torrentMap.contains(torrent));
|
Q_ASSERT(!m_torrentMap.contains(torrent));
|
||||||
|
|||||||
Reference in New Issue
Block a user