summaryrefslogtreecommitdiff
path: root/src/RpcMethod.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-10-21 21:56:42 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-10-21 21:56:42 +0900
commit3832ed97c616eff0057d7a0e5a161c4282537160 (patch)
treeac69085552ddce55eed873ab1b4e359805fc5961 /src/RpcMethod.cc
parent20e781c2df1fa961a09edafe1ff02202278e3636 (diff)
Rewritten Option. Introduced Pref.
Now preference key is Pref instead of just string. It has Option ID. Now option lookup and setting takes O(1) using Pref object.
Diffstat (limited to 'src/RpcMethod.cc')
-rw-r--r--src/RpcMethod.cc25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/RpcMethod.cc b/src/RpcMethod.cc
index c577b7b3..8a49630c 100644
--- a/src/RpcMethod.cc
+++ b/src/RpcMethod.cc
@@ -107,7 +107,7 @@ void gatherOption
// header and index-out option can take array as value
const List* oplist = downcast<List>((*first).second);
if(oplist &&
- (optionName == PREF_HEADER || optionName == PREF_INDEX_OUT)) {
+ (optionName == PREF_HEADER->k || optionName == PREF_INDEX_OUT->k)) {
for(List::ValueType::const_iterator argiter = oplist->begin(),
eoi = oplist->end(); argiter != eoi; ++argiter) {
const String* opval = downcast<String>(*argiter);
@@ -142,8 +142,9 @@ void applyOption(InputIterator optNameFirst,
Option* src)
{
for(; optNameFirst != optNameLast; ++optNameFirst) {
- if(src->defined(*optNameFirst)) {
- dest->put(*optNameFirst, src->get(*optNameFirst));
+ const Pref* pref = option::k2p(*optNameFirst);
+ if(src->defined(pref)) {
+ dest->put(pref, src->get(pref));
}
}
}
@@ -152,10 +153,10 @@ void applyOption(InputIterator optNameFirst,
const std::set<std::string>& listChangeableOptions()
{
static const std::string OPTIONS[] = {
- PREF_BT_MAX_PEERS,
- PREF_BT_REQUEST_PEER_SPEED_LIMIT,
- PREF_MAX_DOWNLOAD_LIMIT,
- PREF_MAX_UPLOAD_LIMIT
+ PREF_BT_MAX_PEERS->k,
+ PREF_BT_REQUEST_PEER_SPEED_LIMIT->k,
+ PREF_MAX_DOWNLOAD_LIMIT->k,
+ PREF_MAX_UPLOAD_LIMIT->k
};
static std::set<std::string> options(vbegin(OPTIONS), vend(OPTIONS));
return options;
@@ -180,11 +181,11 @@ void RpcMethod::applyChangeableOption(Option* dest, Option* src) const
const std::set<std::string>& listChangeableGlobalOptions()
{
static const std::string OPTIONS[] = {
- PREF_MAX_OVERALL_UPLOAD_LIMIT,
- PREF_MAX_OVERALL_DOWNLOAD_LIMIT,
- PREF_MAX_CONCURRENT_DOWNLOADS,
- PREF_LOG,
- PREF_LOG_LEVEL
+ PREF_MAX_OVERALL_UPLOAD_LIMIT->k,
+ PREF_MAX_OVERALL_DOWNLOAD_LIMIT->k,
+ PREF_MAX_CONCURRENT_DOWNLOADS->k,
+ PREF_LOG->k,
+ PREF_LOG_LEVEL->k
};
static std::set<std::string> options(vbegin(OPTIONS), vend(OPTIONS));
return options;