From 976a50384ab3255fbcef120c43b02a9040e8ba54 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 22 Sep 2011 10:37:47 +0000 Subject: [PATCH] some more struct layout optimization --- include/libtorrent/policy.hpp | 2 +- include/libtorrent/torrent.hpp | 16 ++++++++-------- src/torrent.cpp | 15 ++++++++------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/libtorrent/policy.hpp b/include/libtorrent/policy.hpp index 831c333af..ea9dbaeea 100644 --- a/include/libtorrent/policy.hpp +++ b/include/libtorrent/policy.hpp @@ -87,7 +87,7 @@ namespace libtorrent return *this; } private: - unsigned int m_val; + boost::uint16_t m_val; }; enum diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 7d387ff5b..67c9a7231 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -1068,6 +1068,14 @@ namespace libtorrent storage_constructor_type m_storage_constructor; + // the posix time this torrent was added and when + // it was completed. If the torrent isn't yet + // completed, m_completed_time is 0 + time_t m_added_time; + time_t m_completed_time; + time_t m_last_seen_complete; + time_t m_last_saved_resume; + #ifndef TORRENT_DISABLE_ENCRYPTION // this is SHA1("req2" + info-hash), used for // encrypted hand shakes @@ -1093,14 +1101,6 @@ namespace libtorrent boost::uint32_t m_total_failed_bytes; boost::uint32_t m_total_redundant_bytes; - // the posix time this torrent was added and when - // it was completed. If the torrent isn't yet - // completed, m_completed_time is 0 - time_t m_added_time; - time_t m_completed_time; - time_t m_last_seen_complete; - time_t m_last_saved_resume; - // ============================== // The following members are specifically // ordered to make the 24 bit members diff --git a/src/torrent.cpp b/src/torrent.cpp index dfc259028..45b6a8869 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -255,6 +255,10 @@ namespace libtorrent PRINT_OFFSETOF(torrent, m_resume_entry) PRINT_OFFSETOF(torrent, m_name) PRINT_OFFSETOF(torrent, m_storage_constructor) + PRINT_OFFSETOF(torrent, m_added_time) + PRINT_OFFSETOF(torrent, m_completed_time) + PRINT_OFFSETOF(torrent, m_last_seen_complete) + PRINT_OFFSETOF(torrent, m_last_saved_resume) #ifndef TORRENT_DISABLE_ENCRYPTION PRINT_OFFSETOF(torrent, m_obfuscated_hash) #endif @@ -264,9 +268,6 @@ namespace libtorrent PRINT_OFFSETOF(torrent, m_piece_time_deviation) PRINT_OFFSETOF(torrent, m_total_failed_bytes) PRINT_OFFSETOF(torrent, m_total_redundant_bytes) - PRINT_OFFSETOF(torrent, m_added_time) - PRINT_OFFSETOF(torrent, m_completed_time) - PRINT_OFFSETOF(torrent, m_last_seen_complete) // PRINT_OFFSETOF(torrent, m_upload_mode_time:24) // PRINT_OFFSETOF(torrent, m_state:3) // PRINT_OFFSETOF(torrent, m_storage_mode:2) @@ -355,16 +356,16 @@ namespace libtorrent , m_uuid(p.uuid) , m_source_feed_url(p.source_feed_url) , m_storage_constructor(p.storage) + , m_added_time(time(0)) + , m_completed_time(0) + , m_last_seen_complete(0) + , m_last_saved_resume(time(0)) , m_ratio(0.f) , m_available_free_upload(0) , m_average_piece_time(0) , m_piece_time_deviation(0) , m_total_failed_bytes(0) , m_total_redundant_bytes(0) - , m_added_time(time(0)) - , m_completed_time(0) - , m_last_seen_complete(0) - , m_last_saved_resume(time(0)) , m_upload_mode_time(0) , m_state(torrent_status::checking_resume_data) , m_storage_mode(p.storage_mode)