Optimize parameter passing to avoid unnecessary copying

This commit is contained in:
Pugemon 2024-06-07 03:58:20 +03:00
parent 46ca1bb04a
commit f25a425cb9
123 changed files with 578 additions and 522 deletions

View file

@ -31,7 +31,7 @@ std::shared_ptr<Inventory> Inventories::createVirtual(size_t size) {
});
}
void Inventories::store(std::shared_ptr<Inventory> inv) {
void Inventories::store(const std::shared_ptr<Inventory>& inv) {
map[inv->getId()] = inv;
}

View file

@ -28,7 +28,7 @@ public:
std::shared_ptr<Inventory> createVirtual(size_t size);
/* Store inventory */
void store(std::shared_ptr<Inventory> inv);
void store(const std::shared_ptr<Inventory>& inv);
/* Remove inventory from map */
void remove(int64_t id);

View file

@ -1,6 +1,6 @@
#include "ItemDef.hpp"
#include "../util/stringutil.hpp"
ItemDef::ItemDef(std::string name) : name(name) {
ItemDef::ItemDef(const std::string& name) : name(name) {
caption = util::id_to_caption(name);
}

View file

@ -44,7 +44,7 @@ public:
bool emissive = false;
} rt;
ItemDef(std::string name);
ItemDef(const std::string& name);
ItemDef(const ItemDef&) = delete;
};