From 83e26f839d28c5d9aa75aeab7d924fcaad445007 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 5 Apr 2021 13:38:31 +0200 Subject: Reserve vectors before pushing and other code quality changes (#11161) --- src/inventory.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/inventory.cpp') 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 Inventory::getLists() { std::vector 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]; } -- cgit v1.2.3