summaryrefslogtreecommitdiff
path: root/src/Netrc.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-02-28 12:30:11 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-02-28 12:30:11 +0000
commitc342bde9627b434effbc0cd10b817670d1da0923 (patch)
tree60d14bf448066b8dcd639adfa0db716d5a8258c8 /src/Netrc.cc
parent135f0a2a8c4ee04a5e96d84ba558245fabfc1f5c (diff)
2010-02-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use vector instead of deque for containers which is used for mostly read-only purpose.
Diffstat (limited to 'src/Netrc.cc')
-rw-r--r--src/Netrc.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/Netrc.cc b/src/Netrc.cc
index 253c2e5f..40b068b6 100644
--- a/src/Netrc.cc
+++ b/src/Netrc.cc
@@ -36,7 +36,6 @@
#include <fstream>
#include <algorithm>
-#include <vector>
#include "DlAbortEx.h"
#include "StringFormat.h"
@@ -85,7 +84,7 @@ void Netrc::parse(const std::string& path)
SET_ACCOUNT,
SET_MACDEF
};
- AuthenticatorHandle authenticator;
+ SharedHandle<Authenticator> authenticator;
std::string line;
STATE state = GET_TOKEN;
while(getline(f, line)) {
@@ -144,7 +143,7 @@ void Netrc::parse(const std::string& path)
storeAuthenticator(authenticator);
}
-void Netrc::storeAuthenticator(const AuthenticatorHandle& authenticator)
+void Netrc::storeAuthenticator(const SharedHandle<Authenticator>& authenticator)
{
if(!authenticator.isNull()) {
authenticators.push_back(authenticator);
@@ -157,22 +156,23 @@ private:
public:
AuthHostMatch(const std::string& hostname):hostname(hostname) {}
- bool operator()(const AuthenticatorHandle& authenticator)
+ bool operator()(const SharedHandle<Authenticator>& authenticator)
{
return authenticator->match(hostname);
}
};
-AuthenticatorHandle Netrc::findAuthenticator(const std::string& hostname) const
+SharedHandle<Authenticator>
+Netrc::findAuthenticator(const std::string& hostname) const
{
- Authenticators::const_iterator itr =
+ SharedHandle<Authenticator> res;
+ std::vector<SharedHandle<Authenticator> >::const_iterator itr =
std::find_if(authenticators.begin(), authenticators.end(),
AuthHostMatch(hostname));
- if(itr == authenticators.end()) {
- return SharedHandle<Authenticator>();
- } else {
- return *itr;
+ if(itr != authenticators.end()) {
+ res = *itr;
}
+ return res;
}
} // namespace aria2