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
+7 -6
View File
@@ -12,6 +12,7 @@
#include <functional>
#include <map>
#include <queue>
#include <utility>
namespace dynamic {
class Map;
@@ -38,7 +39,7 @@ struct AssetCfg {
struct LayoutCfg : AssetCfg {
scriptenv env;
LayoutCfg(scriptenv env) : env(env) {}
LayoutCfg(scriptenv env) : env(std::move(env)) {}
};
struct SoundCfg : AssetCfg {
@@ -68,11 +69,11 @@ class AssetsLoader {
std::queue<aloader_entry> entries;
const ResPaths* paths;
void tryAddSound(std::string name);
void tryAddSound(const std::string& name);
void processPreload(AssetType tag, const std::string& name, dynamic::Map* map);
void processPreloadList(AssetType tag, dynamic::List* list);
void processPreloadConfig(std::filesystem::path file);
void processPreloadConfig(const std::filesystem::path& file);
void processPreloadConfigs(const Content* content);
public:
AssetsLoader(Assets* assets, const ResPaths* paths);
@@ -85,8 +86,8 @@ public:
/// @param settings asset loading settings (based on asset type)
void add(
AssetType tag,
const std::string filename,
const std::string alias,
const std::string& filename,
const std::string& alias,
std::shared_ptr<AssetCfg> settings=nullptr
);
@@ -106,7 +107,7 @@ public:
static bool loadExternalTexture(
Assets* assets,
const std::string& name,
std::vector<std::filesystem::path> alternatives
const std::vector<std::filesystem::path>& alternatives
);
};