diff --git a/ChangeLog b/ChangeLog index 185ecf7a..7f135e11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-11-17 Tatsuhiro Tsujikawa + + Moved frequently called methods to header file so they get + inlined. + * src/RequestSlot.cc + * src/RequestSlot.h + 2009-11-15 Tatsuhiro Tsujikawa Copied in_addr instead of just casting from char* which might diff --git a/src/RequestSlot.cc b/src/RequestSlot.cc index e1838a35..e007ca62 100644 --- a/src/RequestSlot.cc +++ b/src/RequestSlot.cc @@ -33,59 +33,11 @@ */ /* copyright --> */ #include "RequestSlot.h" -#include "util.h" namespace aria2 { RequestSlot RequestSlot::nullSlot = RequestSlot(); -RequestSlot::RequestSlot(size_t index, uint32_t begin, size_t length, size_t blockIndex, const SharedHandle& piece) - :index(index), begin(begin), length(length), blockIndex(blockIndex), - _piece(piece) {} - -RequestSlot::RequestSlot(const RequestSlot& requestSlot) { - copy(requestSlot); -} - -RequestSlot::RequestSlot():index(0), begin(0), length(0), blockIndex(0) {} - -void RequestSlot::copy(const RequestSlot& requestSlot) { - index = requestSlot.index; - begin = requestSlot.begin; - length = requestSlot.length; - blockIndex = requestSlot.blockIndex; - dispatchedTime = requestSlot.dispatchedTime; - _piece = requestSlot._piece; -} - -RequestSlot& RequestSlot::operator=(const RequestSlot& requestSlot) -{ - if(this != &requestSlot) { - copy(requestSlot); - } - return *this; -} - -bool RequestSlot::operator==(const RequestSlot& requestSlot) const -{ - return index == requestSlot.index && begin == requestSlot.begin - && length == requestSlot.length; -} - -bool RequestSlot::operator!=(const RequestSlot& requestSlot) const -{ - return !(*this == requestSlot); -} - -bool RequestSlot::operator<(const RequestSlot& requestSlot) const -{ - if(index == requestSlot.index) { - return begin < requestSlot.begin; - } else { - return index < requestSlot.index; - } -} - void RequestSlot::setDispatchedTime() { dispatchedTime.reset(); } diff --git a/src/RequestSlot.h b/src/RequestSlot.h index 1c9c6fed..5c25b816 100644 --- a/src/RequestSlot.h +++ b/src/RequestSlot.h @@ -59,24 +59,59 @@ private: // at the construction of RequestSlot as a cache. SharedHandle _piece; - void copy(const RequestSlot& requestSlot); + // inlined for performance reason + void copy(const RequestSlot& requestSlot) + { + index = requestSlot.index; + begin = requestSlot.begin; + length = requestSlot.length; + blockIndex = requestSlot.blockIndex; + dispatchedTime = requestSlot.dispatchedTime; + _piece = requestSlot._piece; + } public: + RequestSlot(size_t index, uint32_t begin, size_t length, size_t blockIndex, - const SharedHandle& piece = SharedHandle()); + const SharedHandle& piece = SharedHandle()): + index(index), begin(begin), length(length), blockIndex(blockIndex), + _piece(piece) {} - RequestSlot(const RequestSlot& requestSlot); + RequestSlot(const RequestSlot& requestSlot) + { + copy(requestSlot); + } - RequestSlot(); + RequestSlot():index(0), begin(0), length(0), blockIndex(0) {} ~RequestSlot() {} - RequestSlot& operator=(const RequestSlot& requestSlot); + RequestSlot& operator=(const RequestSlot& requestSlot) + { + if(this != &requestSlot) { + copy(requestSlot); + } + return *this; + } - bool operator==(const RequestSlot& requestSlot) const; + bool operator==(const RequestSlot& requestSlot) const + { + return index == requestSlot.index && begin == requestSlot.begin + && length == requestSlot.length; + } - bool operator!=(const RequestSlot& requestSlot) const; - - bool operator<(const RequestSlot& requestSlot) const; + bool operator!=(const RequestSlot& requestSlot) const + { + return !(*this == requestSlot); + } + + bool operator<(const RequestSlot& requestSlot) const + { + if(index == requestSlot.index) { + return begin < requestSlot.begin; + } else { + return index < requestSlot.index; + } + } void setDispatchedTime(); void setDispatchedTime(time_t secFromEpoch);