mirror of https://github.com/aria2/aria2
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.hpull/1/head
parent
928de09345
commit
20e734fa15
|
@ -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>
|
2009-11-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Copied in_addr instead of just casting from char* which might
|
Copied in_addr instead of just casting from char* which might
|
||||||
|
|
|
@ -33,59 +33,11 @@
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "RequestSlot.h"
|
#include "RequestSlot.h"
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
RequestSlot RequestSlot::nullSlot = RequestSlot();
|
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() {
|
void RequestSlot::setDispatchedTime() {
|
||||||
dispatchedTime.reset();
|
dispatchedTime.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,24 +59,59 @@ private:
|
||||||
// at the construction of RequestSlot as a cache.
|
// at the construction of RequestSlot as a cache.
|
||||||
SharedHandle<Piece> _piece;
|
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:
|
public:
|
||||||
|
|
||||||
RequestSlot(size_t index, uint32_t begin, size_t length, size_t blockIndex,
|
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() {}
|
||||||
|
|
||||||
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();
|
||||||
void setDispatchedTime(time_t secFromEpoch);
|
void setDispatchedTime(time_t secFromEpoch);
|
||||||
|
|
Loading…
Reference in New Issue