remove resolve_links disk job left-overs and convert some C-arrays to std::array

This commit is contained in:
arvidn 2017-06-12 14:08:45 +02:00 committed by Arvid Norberg
parent 48ef3b6bf7
commit 9a19ff344b
4 changed files with 13 additions and 15 deletions

View File

@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <list>
#include <vector>
#include <unordered_set>
#include <array>
#include "libtorrent/time.hpp"
#include "libtorrent/error_code.hpp"
@ -92,7 +93,7 @@ namespace aux {
};
explicit piece_log_t(artificial_jobs j, int b = -1): job(static_cast<job_action_t>(j)), block(b) {}
static char const* const job_names[7];
static std::array<char const*, 7> const job_names;
};
char const* job_name(job_action_t j);
@ -104,7 +105,7 @@ namespace aux {
void assert_print_piece(cached_piece_entry const* pe);
#endif
extern const char* const job_action_name[];
extern std::array<const char*, 15> const job_action_name;
struct TORRENT_EXTRA_EXPORT partial_hash
{

View File

@ -75,7 +75,6 @@ namespace libtorrent {
, trim_cache
, file_priority
, clear_piece
, resolve_links
, num_job_ids
};

View File

@ -382,7 +382,6 @@ namespace aux {
status_t do_trim_cache(disk_io_job* j, jobqueue_t& completed_jobs);
status_t do_file_priority(disk_io_job* j, jobqueue_t& completed_jobs);
status_t do_clear_piece(disk_io_job* j, jobqueue_t& completed_jobs);
status_t do_resolve_links(disk_io_job* j, jobqueue_t& completed_jobs);
void call_job_handlers();

View File

@ -188,8 +188,8 @@ void log_refcounts(cached_piece_entry const* pe)
}
#endif
const char* const job_action_name[] =
{
std::array<const char*, 15> const job_action_name =
{{
"read",
"write",
"hash",
@ -205,17 +205,16 @@ const char* const job_action_name[] =
"trim_cache",
"set_file_priority",
"clear_piece",
"resolve_links"
};
}};
// make sure the job names array covers all the job IDs
static_assert(sizeof(job_action_name)/sizeof(job_action_name[0])
== static_cast<int>(job_action_t::num_job_ids), "disk-job-action and action-name-array mismatch");
static_assert(int(job_action_name.size()) == static_cast<int>(job_action_t::num_job_ids)
, "disk-job-action and action-name-array mismatch");
#if TORRENT_USE_ASSERTS || !defined TORRENT_DISABLE_LOGGING
char const* const piece_log_t::job_names[7] =
{
std::array<char const*, 7> const piece_log_t::job_names =
{{
"flushing",
"flush_expired",
"try_flush_write_blocks",
@ -223,7 +222,7 @@ static_assert(sizeof(job_action_name)/sizeof(job_action_name[0])
"flush_range",
"clear_outstanding_jobs",
"set_outstanding_jobs",
};
}};
char const* job_name(job_action_t const job)
{
@ -232,8 +231,8 @@ static_assert(sizeof(job_action_name)/sizeof(job_action_name[0])
return "unknown";
if (j < piece_log_t::flushing)
return job_action_name[j];
return piece_log_t::job_names[j - piece_log_t::flushing];
return job_action_name[static_cast<std::size_t>(j)];
return piece_log_t::job_names[static_cast<std::size_t>(j - piece_log_t::flushing)];
}
#endif // TORRENT_DISABLE_LOGGING