From 2ba0e5ae2ce35df31f3261c97dca31836579bb1b Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 8 Jul 2018 14:36:32 +0200 Subject: [PATCH] move the file priority vector throught the disk_io_job, to avoid copies --- include/libtorrent/disk_interface.hpp | 2 +- include/libtorrent/disk_io_job.hpp | 2 +- include/libtorrent/disk_io_thread.hpp | 2 +- include/libtorrent/torrent.hpp | 2 +- src/disk_io_job.cpp | 2 +- src/disk_io_thread.cpp | 2 +- src/torrent.cpp | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/libtorrent/disk_interface.hpp b/include/libtorrent/disk_interface.hpp index 5020022a4..ab8f325a2 100644 --- a/include/libtorrent/disk_interface.hpp +++ b/include/libtorrent/disk_interface.hpp @@ -172,7 +172,7 @@ namespace libtorrent { , std::function handler) = 0; virtual void async_set_file_priority(storage_index_t storage , aux::vector prio - , std::function const&)> handler) = 0; + , std::function)> handler) = 0; virtual void async_clear_piece(storage_index_t storage, piece_index_t index , std::function handler) = 0; diff --git a/include/libtorrent/disk_io_job.hpp b/include/libtorrent/disk_io_job.hpp index 792cb8738..0fb4fb786 100644 --- a/include/libtorrent/disk_io_job.hpp +++ b/include/libtorrent/disk_io_job.hpp @@ -138,7 +138,7 @@ namespace libtorrent { using check_handler = std::function; using rename_handler = std::function; using clear_piece_handler = std::function; - using set_file_prio_handler = std::function const&)>; + using set_file_prio_handler = std::function)>; boost::variant handler = std::function()) override; void async_set_file_priority(storage_index_t storage , aux::vector prio - , std::function const&)> handler) override; + , std::function)> handler) override; void async_clear_piece(storage_index_t storage, piece_index_t index , std::function handler) override; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 62a230d97..63afbdc79 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -569,7 +569,7 @@ namespace libtorrent { void set_file_priority(file_index_t index, download_priority_t priority); download_priority_t file_priority(file_index_t index) const; - void on_file_priority(storage_error const& err, aux::vector const& prios); + void on_file_priority(storage_error const& err, aux::vector prios); void prioritize_files(aux::vector const& files); void file_priorities(aux::vector*) const; diff --git a/src/disk_io_job.cpp b/src/disk_io_job.cpp index 29d3036e2..75d5b90ba 100644 --- a/src/disk_io_job.cpp +++ b/src/disk_io_job.cpp @@ -100,7 +100,7 @@ namespace libtorrent { void operator()(disk_io_job::set_file_prio_handler& h) const { if (!h) return; - h(m_job.error, boost::get>(m_job.argument)); + h(m_job.error, std::move(boost::get>(m_job.argument))); } private: diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 479460903..4f9f8e0a0 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -1920,7 +1920,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit; void disk_io_thread::async_set_file_priority(storage_index_t const storage , aux::vector prios - , std::function const&)> handler) + , std::function)> handler) { disk_io_job* j = allocate_job(job_action_t::file_priority); j->storage = m_torrents[storage]->shared_from_this(); diff --git a/src/torrent.cpp b/src/torrent.cpp index 5b3f8c31a..5d2db5437 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -5041,12 +5041,12 @@ bool is_downloading_state(int const st) } void torrent::on_file_priority(storage_error const& err - , aux::vector const& prios) + , aux::vector prios) { COMPLETE_ASYNC("file_priority"); if (m_file_priority != prios) { - m_file_priority = prios; + m_file_priority = std::move(prios); update_piece_priorities(); if (m_share_mode) recalc_share_mode();