summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-09-24 23:20:43 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-09-24 23:20:43 +0900
commitd8c44fe9e8cc73903fba710490c59016d5dfd972 (patch)
tree409f2bcd464efcc055668f0930fa03b792d54ebf /src
parent0144397e4b3897035d76c40827d7f8a753868f2a (diff)
Use const char* instead of static const std::string
Diffstat (limited to 'src')
-rw-r--r--src/DefaultBtInteractive.cc3
-rw-r--r--src/Logger.cc29
-rw-r--r--src/RequestGroup.cc4
-rw-r--r--src/RequestGroupMan.cc21
-rw-r--r--src/RequestGroupMan.h4
-rw-r--r--src/Sqlite3CookieParser.cc2
-rw-r--r--src/Sqlite3CookieParser.h2
-rw-r--r--src/Sqlite3CookieParserImpl.cc10
-rw-r--r--src/Sqlite3CookieParserImpl.h4
-rw-r--r--src/TrackerWatcherCommand.cc3
10 files changed, 30 insertions, 52 deletions
diff --git a/src/DefaultBtInteractive.cc b/src/DefaultBtInteractive.cc
index af3df1b5..7b9816bc 100644
--- a/src/DefaultBtInteractive.cc
+++ b/src/DefaultBtInteractive.cc
@@ -187,9 +187,8 @@ void DefaultBtInteractive::addPortMessageToQueue()
void DefaultBtInteractive::addHandshakeExtendedMessageToQueue()
{
- static const std::string CLIENT_ARIA2("aria2/"PACKAGE_VERSION);
HandshakeExtensionMessageHandle m(new HandshakeExtensionMessage());
- m->setClientVersion(CLIENT_ARIA2);
+ m->setClientVersion("aria2/" PACKAGE_VERSION);
m->setTCPPort(tcpPort_);
m->setExtensions(extensionMessageRegistry_->getExtensions());
SharedHandle<TorrentAttribute> attrs =
diff --git a/src/Logger.cc b/src/Logger.cc
index 3e3ee814..a123db01 100644
--- a/src/Logger.cc
+++ b/src/Logger.cc
@@ -48,18 +48,6 @@
namespace aria2 {
-namespace {
-static const std::string DEBUG_LABEL("DEBUG");
-
-static const std::string INFO_LABEL("INFO");
-
-static const std::string NOTICE_LABEL("NOTICE");
-
-static const std::string WARN_LABEL("WARN");
-
-static const std::string ERROR_LABEL("ERROR");
-} // namespace
-
Logger::Logger()
: logLevel_(Logger::A2_DEBUG),
stdoutField_(0)
@@ -104,21 +92,21 @@ bool Logger::levelEnabled(LEVEL level)
}
namespace {
-const std::string& levelToString(Logger::LEVEL level)
+const char* levelToString(Logger::LEVEL level)
{
switch(level) {
case Logger::A2_DEBUG:
- return DEBUG_LABEL;
+ return "DEBUG";
case Logger::A2_INFO:
- return INFO_LABEL;
+ return "INFO";
case Logger::A2_NOTICE:
- return NOTICE_LABEL;
+ return "NOTICE";
case Logger::A2_WARN:
- return WARN_LABEL;
+ return "WARN";
case Logger::A2_ERROR:
- return ERROR_LABEL;
+ return "ERROR";
default:
- return A2STR::NIL;
+ return "";
}
}
} // namespace
@@ -138,8 +126,7 @@ void writeHeader
size_t dateLength =
strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", &tm);
assert(dateLength <= (size_t)20);
- fp.printf("%s.%06ld %s - ", datestr, tv.tv_usec,
- levelToString(level).c_str());
+ fp.printf("%s.%06ld %s - ", datestr, tv.tv_usec, levelToString(level));
if(sourceFile) {
fp.printf("[%s:%d]", sourceFile, lineNum);
}
diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc
index 18522c53..9f5f8690 100644
--- a/src/RequestGroup.cc
+++ b/src/RequestGroup.cc
@@ -846,8 +846,8 @@ std::string RequestGroup::getFirstFilePath() const
{
assert(downloadContext_);
if(inMemoryDownload()) {
- static const std::string DIR_MEMORY("[MEMORY]");
- return DIR_MEMORY+File(downloadContext_->getFirstFileEntry()->getPath()).getBasename();
+ return "[MEMORY]"+
+ File(downloadContext_->getFirstFileEntry()->getPath()).getBasename();
} else {
return downloadContext_->getFirstFileEntry()->getPath();
}
diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc
index 4206aac9..0e8ea1da 100644
--- a/src/RequestGroupMan.cc
+++ b/src/RequestGroupMan.cc
@@ -713,11 +713,6 @@ RequestGroupMan::DownloadStat RequestGroupMan::getDownloadStat() const
void RequestGroupMan::showDownloadResults(OutputFile& o, bool full) const
{
- static const std::string MARK_OK("OK");
- static const std::string MARK_ERR("ERR");
- static const std::string MARK_INPR("INPR");
- static const std::string MARK_RM("RM");
-
#ifdef __MINGW32__
int pathRowSize = 58;
#else // !__MINGW32__
@@ -749,18 +744,18 @@ void RequestGroupMan::showDownloadResults(OutputFile& o, bool full) const
if((*itr)->belongsTo != 0) {
continue;
}
- std::string status;
+ const char* status;
if((*itr)->result == error_code::FINISHED) {
- status = MARK_OK;
+ status = "OK";
++ok;
} else if((*itr)->result == error_code::IN_PROGRESS) {
- status = MARK_INPR;
+ status = "INPR";
++inpr;
} else if((*itr)->result == error_code::REMOVED) {
- status = MARK_RM;
+ status = "RM";
++rm;
} else {
- status = MARK_ERR;
+ status = "ERR";
++err;
}
if(full) {
@@ -791,7 +786,7 @@ void RequestGroupMan::showDownloadResults(OutputFile& o, bool full) const
namespace {
void formatDownloadResultCommon
(std::ostream& o,
- const std::string& status,
+ const char* status,
const DownloadResultHandle& downloadResult)
{
o << std::setw(3) << downloadResult->gid << "|"
@@ -810,7 +805,7 @@ void formatDownloadResultCommon
void RequestGroupMan::formatDownloadResultFull
(OutputFile& out,
- const std::string& status,
+ const char* status,
const DownloadResultHandle& downloadResult) const
{
BitfieldMan bt(downloadResult->pieceLength, downloadResult->totalLength);
@@ -852,7 +847,7 @@ void RequestGroupMan::formatDownloadResultFull
}
std::string RequestGroupMan::formatDownloadResult
-(const std::string& status,
+(const char* status,
const DownloadResultHandle& downloadResult) const
{
std::stringstream o;
diff --git a/src/RequestGroupMan.h b/src/RequestGroupMan.h
index 93b2f91e..4bdc9f66 100644
--- a/src/RequestGroupMan.h
+++ b/src/RequestGroupMan.h
@@ -94,11 +94,11 @@ private:
void formatDownloadResultFull
(OutputFile& out,
- const std::string& status,
+ const char* status,
const DownloadResultHandle& downloadResult) const;
std::string formatDownloadResult
- (const std::string& status,
+ (const char* status,
const DownloadResultHandle& downloadResult) const;
void configureRequestGroup
diff --git a/src/Sqlite3CookieParser.cc b/src/Sqlite3CookieParser.cc
index b9d705d0..ed89aef7 100644
--- a/src/Sqlite3CookieParser.cc
+++ b/src/Sqlite3CookieParser.cc
@@ -146,7 +146,7 @@ void Sqlite3CookieParser::parse(std::vector<Cookie>& cookies)
}
std::vector<Cookie> tcookies;
char* sqlite3ErrMsg = 0;
- int ret = sqlite3_exec(db_, getQuery().c_str(), cookieRowMapper,
+ int ret = sqlite3_exec(db_, getQuery(), cookieRowMapper,
&tcookies, &sqlite3ErrMsg);
std::string errMsg;
if(sqlite3ErrMsg) {
diff --git a/src/Sqlite3CookieParser.h b/src/Sqlite3CookieParser.h
index e8679294..24b590df 100644
--- a/src/Sqlite3CookieParser.h
+++ b/src/Sqlite3CookieParser.h
@@ -61,7 +61,7 @@ protected:
// must return 6 columns in the following order: host, path,
// secure(1 for secure, 0 for not), expiry(utc, unix time), name,
// value, last access time(utc, unix time)
- virtual const std::string& getQuery() const = 0;
+ virtual const char* getQuery() const = 0;
private:
sqlite3* db_;
};
diff --git a/src/Sqlite3CookieParserImpl.cc b/src/Sqlite3CookieParserImpl.cc
index 07fb262c..f5c6fe52 100644
--- a/src/Sqlite3CookieParserImpl.cc
+++ b/src/Sqlite3CookieParserImpl.cc
@@ -41,12 +41,11 @@ Sqlite3MozCookieParser::Sqlite3MozCookieParser(const std::string& filename):
Sqlite3MozCookieParser::~Sqlite3MozCookieParser() {}
-const std::string& Sqlite3MozCookieParser::getQuery() const
+const char* Sqlite3MozCookieParser::getQuery() const
{
- static const std::string sql =
+ return
"SELECT host, path, isSecure, expiry, name, value, lastAccessed"
" FROM moz_cookies";
- return sql;
}
Sqlite3ChromiumCookieParser::Sqlite3ChromiumCookieParser
@@ -54,12 +53,11 @@ Sqlite3ChromiumCookieParser::Sqlite3ChromiumCookieParser
Sqlite3ChromiumCookieParser::~Sqlite3ChromiumCookieParser() {}
-const std::string& Sqlite3ChromiumCookieParser::getQuery() const
+const char* Sqlite3ChromiumCookieParser::getQuery() const
{
- static const std::string sql =
+ return
"SELECT host_key, path, secure, expires_utc, name, value, last_access_utc"
" FROM cookies";
- return sql;
}
} // namespace aria2
diff --git a/src/Sqlite3CookieParserImpl.h b/src/Sqlite3CookieParserImpl.h
index 081a8869..20a53d42 100644
--- a/src/Sqlite3CookieParserImpl.h
+++ b/src/Sqlite3CookieParserImpl.h
@@ -44,7 +44,7 @@ public:
Sqlite3MozCookieParser(const std::string& filename);
virtual ~Sqlite3MozCookieParser();
protected:
- virtual const std::string& getQuery() const;
+ virtual const char* getQuery() const;
};
class Sqlite3ChromiumCookieParser:public Sqlite3CookieParser {
@@ -52,7 +52,7 @@ public:
Sqlite3ChromiumCookieParser(const std::string& filename);
virtual ~Sqlite3ChromiumCookieParser();
protected:
- virtual const std::string& getQuery() const;
+ virtual const char* getQuery() const;
};
} // namespace aria2
diff --git a/src/TrackerWatcherCommand.cc b/src/TrackerWatcherCommand.cc
index ff25e4f2..00822a4f 100644
--- a/src/TrackerWatcherCommand.cc
+++ b/src/TrackerWatcherCommand.cc
@@ -240,11 +240,10 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri)
option->get(PREF_BT_TRACKER_CONNECT_TIMEOUT));
option->put(PREF_REUSE_URI, A2_V_FALSE);
option->put(PREF_SELECT_LEAST_USED_HOST, A2_V_FALSE);
- static const std::string TRACKER_ANNOUNCE_FILE("[tracker.announce]");
SharedHandle<DownloadContext> dctx
(new DownloadContext(option->getAsInt(PREF_PIECE_LENGTH),
0,
- TRACKER_ANNOUNCE_FILE));
+ "[tracker.announce]"));
dctx->getFileEntries().front()->setUris(uris);
rg->setDownloadContext(dctx);
SharedHandle<DiskWriterFactory> dwf(new ByteArrayDiskWriterFactory());