aboutsummaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-04-05 13:38:31 +0200
committerGitHub <noreply@github.com>2021-04-05 13:38:31 +0200
commitf0bad0e2badbb7d4777aac7de1b50239bca4010a (patch)
tree4c3115a42ac86e9a64d9e5f088fe187022885779 /src/inventory.cpp
parent3e1904fa8c4aae3448d58b7e60545a4fdd8234f3 (diff)
downloadhax-minetest-server-f0bad0e2badbb7d4777aac7de1b50239bca4010a.tar.gz
hax-minetest-server-f0bad0e2badbb7d4777aac7de1b50239bca4010a.zip
Reserve vectors before pushing and other code quality changes (#11161)
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 1ef9b13cd..fc1aaf371 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -965,13 +965,14 @@ InventoryList * Inventory::getList(const std::string &name)
{
s32 i = getListIndex(name);
if(i == -1)
- return NULL;
+ return nullptr;
return m_lists[i];
}
std::vector<const InventoryList*> Inventory::getLists()
{
std::vector<const InventoryList*> lists;
+ lists.reserve(m_lists.size());
for (auto list : m_lists) {
lists.push_back(list);
}
@@ -990,11 +991,11 @@ bool Inventory::deleteList(const std::string &name)
return true;
}
-const InventoryList * Inventory::getList(const std::string &name) const
+const InventoryList *Inventory::getList(const std::string &name) const
{
s32 i = getListIndex(name);
if(i == -1)
- return NULL;
+ return nullptr;
return m_lists[i];
}