2009-11-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Moved frequently called methods to header file so they get
	inlined.
	* src/RequestSlot.cc
	* src/RequestSlot.h
pull/1/head
Tatsuhiro Tsujikawa 2009-11-17 14:29:55 +00:00
parent 928de09345
commit 20e734fa15
3 changed files with 51 additions and 57 deletions

View File

@ -1,3 +1,10 @@
2009-11-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Moved frequently called methods to header file so they get
inlined.
* src/RequestSlot.cc
* src/RequestSlot.h
2009-11-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Copied in_addr instead of just casting from char* which might

View File

@ -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>& 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();
}

View File

@ -59,24 +59,59 @@ private:
// at the construction of RequestSlot as a cache.
SharedHandle<Piece> _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>& piece = SharedHandle<Piece>());
const SharedHandle<Piece>& piece = SharedHandle<Piece>()):
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
{
return !(*this == requestSlot);
}
bool operator<(const RequestSlot& requestSlot) const;
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);