summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-06-09 17:13:40 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-06-09 17:13:40 +0200
commit51561c4de75e84c2b2d037eb57387d3d3c2aa494 (patch)
treea4a3bb059ffc72ffe32f872518efecef636ebb63
parent9ee8287e5ea8a993fbb4c5beb8fe8bbddadfa7a0 (diff)
fix compiler warning in the new mirror code
-rw-r--r--methods/http.h2
-rw-r--r--methods/mirror.cc27
2 files changed, 17 insertions, 12 deletions
diff --git a/methods/http.h b/methods/http.h
index d0677bdaa..0bc019e77 100644
--- a/methods/http.h
+++ b/methods/http.h
@@ -13,7 +13,7 @@
#define MAXLEN 360
-
+#include <apt-pkg/hashes.h>
using std::cout;
using std::endl;
diff --git a/methods/mirror.cc b/methods/mirror.cc
index b2b6b2ecf..e8873d97b 100644
--- a/methods/mirror.cc
+++ b/methods/mirror.cc
@@ -153,11 +153,12 @@ void MirrorMethod::CurrentQueueUriToMirror()
return;
// find current mirror and select next one
- for (int i=0; i < AllMirrors.size(); i++)
+ for (vector<string>::const_iterator mirror = AllMirrors.begin();
+ mirror != AllMirrors.end(); ++mirror)
{
- if (Queue->Uri.find(AllMirrors[i]) == 0)
+ if (Queue->Uri.find(*mirror) == 0)
{
- Queue->Uri.replace(0, AllMirrors[i].size(), BaseUri);
+ Queue->Uri.replace(0, mirror->length(), BaseUri);
return;
}
}
@@ -168,15 +169,19 @@ void MirrorMethod::CurrentQueueUriToMirror()
bool MirrorMethod::TryNextMirror()
{
// find current mirror and select next one
- for (int i=0; i < AllMirrors.size()-1; i++)
+ for (vector<string>::const_iterator mirror = AllMirrors.begin();
+ mirror != AllMirrors.end(); ++mirror)
{
- if (Queue->Uri.find(AllMirrors[i]) == 0)
- {
- Queue->Uri.replace(0, AllMirrors[i].size(), AllMirrors[i+1]);
- if (Debug)
- clog << "TryNextMirror: " << Queue->Uri << endl;
- return true;
- }
+ if (Queue->Uri.find(*mirror) != 0)
+ continue;
+
+ vector<string>::const_iterator nextmirror = mirror + 1;
+ if (nextmirror != AllMirrors.end())
+ break;
+ Queue->Uri.replace(0, mirror->length(), *nextmirror);
+ if (Debug)
+ clog << "TryNextMirror: " << Queue->Uri << endl;
+ return true;
}
if (Debug)