Optimize parameter passing to avoid unnecessary copying
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
bool emissive = false;
|
||||
} rt;
|
||||
|
||||
ItemDef(std::string name);
|
||||
ItemDef(const std::string& name);
|
||||
ItemDef(const ItemDef&) = delete;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user