aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-12-26 17:01:41 +0100
committerest31 <MTest31@outlook.com>2015-12-29 00:39:42 +0100
commit8a46c5df1c1b7d7c2b46b73f973a45388a517e71 (patch)
tree34a1caf706313e5a43ed656df7f6f070724f6d04
parent382ab969d4de29cd5f74db2de433a37254d40d2a (diff)
downloadminetest-8a46c5df1c1b7d7c2b46b73f973a45388a517e71.tar.gz
minetest-8a46c5df1c1b7d7c2b46b73f973a45388a517e71.tar.bz2
minetest-8a46c5df1c1b7d7c2b46b73f973a45388a517e71.zip
Database backends: fix bug, and small speedup
-> Redis backend: break from switch to fix bug -> Dummy and redis backends: reserve the count so that creating the list is faster
-rw-r--r--src/database-dummy.cpp1
-rw-r--r--src/database-redis.cpp2
2 files changed, 3 insertions, 0 deletions
diff --git a/src/database-dummy.cpp b/src/database-dummy.cpp
index 2e5de5ed1..b38db1fb9 100644
--- a/src/database-dummy.cpp
+++ b/src/database-dummy.cpp
@@ -47,6 +47,7 @@ bool Database_Dummy::deleteBlock(const v3s16 &pos)
void Database_Dummy::listAllLoadableBlocks(std::vector<v3s16> &dst)
{
+ dst.reserve(m_database.size());
for (std::map<s64, std::string>::const_iterator x = m_database.begin();
x != m_database.end(); ++x) {
dst.push_back(getIntegerAsBlock(x->first));
diff --git a/src/database-redis.cpp b/src/database-redis.cpp
index b15f546b2..196d72f25 100644
--- a/src/database-redis.cpp
+++ b/src/database-redis.cpp
@@ -169,10 +169,12 @@ void Database_Redis::listAllLoadableBlocks(std::vector<v3s16> &dst)
}
switch (reply->type) {
case REDIS_REPLY_ARRAY:
+ dst.reserve(reply->elements);
for (size_t i = 0; i < reply->elements; i++) {
assert(reply->element[i]->type == REDIS_REPLY_STRING);
dst.push_back(getIntegerAsBlock(stoi64(reply->element[i]->str)));
}
+ break;
case REDIS_REPLY_ERROR:
throw FileNotGoodException(std::string(
"Failed to get keys from database: ") + reply->str);