diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-09-25 00:01:00 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-09-25 00:01:00 +0900 |
| commit | b640b830a20a09cd5677616918850b39953f0bcd (patch) | |
| tree | 323b1dd553da99d2d27762eece32dadcbe3e543f /src/ServerStat.cc | |
| parent | a8c079464079789132221f093d27706ab973a86a (diff) | |
Made STATUS_STRING const char*[]
Diffstat (limited to 'src/ServerStat.cc')
| -rw-r--r-- | src/ServerStat.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/ServerStat.cc b/src/ServerStat.cc index 23bae375..7bf9fdd1 100644 --- a/src/ServerStat.cc +++ b/src/ServerStat.cc @@ -46,10 +46,12 @@ namespace aria2 { -const std::string ServerStat::STATUS_STRING[] = { +namespace { +const char* STATUS_STRING[] = { "OK", "ERROR" }; +} // namespace ServerStat::ServerStat(const std::string& hostname, const std::string& protocol) : hostname_(hostname), @@ -161,18 +163,18 @@ void ServerStat::setStatus(STATUS status) void ServerStat::setStatus(const std::string& status) { - const std::string* p = std::find(vbegin(STATUS_STRING), vend(STATUS_STRING), - status); - if(p != vend(STATUS_STRING)) { - status_ = static_cast<STATUS>(ServerStat::OK+ - std::distance(vbegin(STATUS_STRING), p)); + for(int i = 0; i < MAX_STATUS; ++i) { + if(strcmp(status.c_str(), STATUS_STRING[i]) == 0) { + status_ = static_cast<STATUS>(i); + break; + } } } void ServerStat::setStatusInternal(STATUS status) { A2_LOG_DEBUG(fmt("ServerStat: set status %s for %s (%s)", - STATUS_STRING[status].c_str(), + STATUS_STRING[status], hostname_.c_str(), protocol_.c_str())); status_ = status; @@ -211,7 +213,7 @@ std::string ServerStat::toString() const getMultiConnectionAvgSpeed(), getLastUpdated().getTime(), getCounter(), - ServerStat::STATUS_STRING[getStatus()].c_str()); + STATUS_STRING[getStatus()]); } } // namespace aria2 |
