Optimize parameter passing to avoid unnecessary copying

This commit is contained in:
Pugemon
2024-06-07 04:00:38 +03:00
parent 46ca1bb04a
commit f25a425cb9
123 changed files with 578 additions and 522 deletions
+1 -1
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;
}
+1 -1
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);
+1 -1
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);
}
+1 -1
View File
@@ -44,7 +44,7 @@ public:
bool emissive = false;
} rt;
ItemDef(std::string name);
ItemDef(const std::string& name);
ItemDef(const ItemDef&) = delete;
};