aboutsummaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-04-05 13:38:31 +0200
committerrubenwardy <rw@rubenwardy.com>2021-10-20 14:25:39 +0100
commit83e26f839d28c5d9aa75aeab7d924fcaad445007 (patch)
treeff2617af2c8d2ca1b8742c64a28bd659def66743 /src/inventory.cpp
parentc3f7905d82e5b1201d81378dedde746caf0e2451 (diff)
downloadminetest-83e26f839d28c5d9aa75aeab7d924fcaad445007.tar.gz
minetest-83e26f839d28c5d9aa75aeab7d924fcaad445007.tar.bz2
minetest-83e26f839d28c5d9aa75aeab7d924fcaad445007.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];
}