summaryrefslogtreecommitdiff
path: root/src/httpfetch.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-03-05 16:20:56 +0100
committerLoic Blot <loic.blot@unix-experience.fr>2015-03-05 16:21:10 +0100
commit3d505b2b5f6cf6a8c3475a40991d7d1f8ef75365 (patch)
treeea996dd86e5316854b94d37e6fd18aee234dec12 /src/httpfetch.cpp
parent9749d9fee6db99da1ab861dc04ec63ef973db3e0 (diff)
downloadminetest-3d505b2b5f6cf6a8c3475a40991d7d1f8ef75365.tar.gz
minetest-3d505b2b5f6cf6a8c3475a40991d7d1f8ef75365.tar.bz2
minetest-3d505b2b5f6cf6a8c3475a40991d7d1f8ef75365.zip
Use std::queue for HTTPFetchRequest and std::vector for log_output instead of std::list
Diffstat (limited to 'src/httpfetch.cpp')
-rw-r--r--src/httpfetch.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/httpfetch.cpp b/src/httpfetch.cpp
index 981643f6c..e6886f652 100644
--- a/src/httpfetch.cpp
+++ b/src/httpfetch.cpp
@@ -37,7 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
JMutex g_httpfetch_mutex;
-std::map<unsigned long, std::list<HTTPFetchResult> > g_httpfetch_results;
+std::map<unsigned long, std::queue<HTTPFetchResult> > g_httpfetch_results;
HTTPFetchRequest::HTTPFetchRequest()
{
@@ -57,7 +57,7 @@ static void httpfetch_deliver_result(const HTTPFetchResult &fetch_result)
unsigned long caller = fetch_result.caller;
if (caller != HTTPFETCH_DISCARD) {
JMutexAutoLock lock(g_httpfetch_mutex);
- g_httpfetch_results[caller].push_back(fetch_result);
+ g_httpfetch_results[caller].push(fetch_result);
}
}
@@ -70,11 +70,11 @@ unsigned long httpfetch_caller_alloc()
// Check each caller ID except HTTPFETCH_DISCARD
const unsigned long discard = HTTPFETCH_DISCARD;
for (unsigned long caller = discard + 1; caller != discard; ++caller) {
- std::map<unsigned long, std::list<HTTPFetchResult> >::iterator
+ std::map<unsigned long, std::queue<HTTPFetchResult> >::iterator
it = g_httpfetch_results.find(caller);
if (it == g_httpfetch_results.end()) {
- verbosestream<<"httpfetch_caller_alloc: allocating "
- <<caller<<std::endl;
+ verbosestream << "httpfetch_caller_alloc: allocating "
+ << caller << std::endl;
// Access element to create it
g_httpfetch_results[caller];
return caller;
@@ -102,19 +102,19 @@ bool httpfetch_async_get(unsigned long caller, HTTPFetchResult &fetch_result)
JMutexAutoLock lock(g_httpfetch_mutex);
// Check that caller exists
- std::map<unsigned long, std::list<HTTPFetchResult> >::iterator
+ std::map<unsigned long, std::queue<HTTPFetchResult> >::iterator
it = g_httpfetch_results.find(caller);
if (it == g_httpfetch_results.end())
return false;
// Check that result queue is nonempty
- std::list<HTTPFetchResult> &caller_results = it->second;
+ std::queue<HTTPFetchResult> &caller_results = it->second;
if (caller_results.empty())
return false;
// Pop first result
fetch_result = caller_results.front();
- caller_results.pop_front();
+ caller_results.pop();
return true;
}