Optimize parameter passing to avoid unnecessary copying
This commit is contained in:
@@ -27,7 +27,7 @@ static debug::Logger logger("engine-control");
|
||||
EngineController::EngineController(Engine* engine) : engine(engine) {
|
||||
}
|
||||
|
||||
void EngineController::deleteWorld(std::string name) {
|
||||
void EngineController::deleteWorld(const std::string& name) {
|
||||
fs::path folder = engine->getPaths()->getWorldFolder(name);
|
||||
guiutil::confirm(engine->getGUI(), langs::get(L"delete-confirm", L"world")+
|
||||
L" ("+util::str2wstr_utf8(folder.u8string())+L")", [=]() {
|
||||
@@ -38,10 +38,10 @@ void EngineController::deleteWorld(std::string name) {
|
||||
|
||||
std::shared_ptr<Task> create_converter(
|
||||
Engine* engine,
|
||||
fs::path folder,
|
||||
const fs::path& folder,
|
||||
const Content* content,
|
||||
std::shared_ptr<ContentLUT> lut,
|
||||
runnable postRunnable)
|
||||
const std::shared_ptr<ContentLUT>& lut,
|
||||
const runnable& postRunnable)
|
||||
{
|
||||
return WorldConverter::startTask(folder, content, lut, [=](){
|
||||
auto menu = engine->getGUI()->getMenu();
|
||||
@@ -56,9 +56,9 @@ std::shared_ptr<Task> create_converter(
|
||||
void show_convert_request(
|
||||
Engine* engine,
|
||||
const Content* content,
|
||||
std::shared_ptr<ContentLUT> lut,
|
||||
fs::path folder,
|
||||
runnable postRunnable
|
||||
const std::shared_ptr<ContentLUT>& lut,
|
||||
const fs::path& folder,
|
||||
const runnable& postRunnable
|
||||
) {
|
||||
guiutil::confirm(engine->getGUI(), langs::get(L"world.convert-request"), [=]() {
|
||||
auto converter = create_converter(engine, folder, content, lut, postRunnable);
|
||||
@@ -68,7 +68,7 @@ void show_convert_request(
|
||||
|
||||
static void show_content_missing(
|
||||
Engine* engine,
|
||||
std::shared_ptr<ContentLUT> lut
|
||||
const std::shared_ptr<ContentLUT>& lut
|
||||
) {
|
||||
using namespace dynamic;
|
||||
auto root = create_map();
|
||||
@@ -82,7 +82,7 @@ static void show_content_missing(
|
||||
menus::show(engine, "reports/missing_content", {root});
|
||||
}
|
||||
|
||||
static bool loadWorldContent(Engine* engine, fs::path folder) {
|
||||
static bool loadWorldContent(Engine* engine, const fs::path& folder) {
|
||||
try {
|
||||
engine->loadWorldContent(folder);
|
||||
return true;
|
||||
@@ -104,7 +104,7 @@ static bool loadWorldContent(Engine* engine, fs::path folder) {
|
||||
}
|
||||
}
|
||||
|
||||
static void loadWorld(Engine* engine, fs::path folder) {
|
||||
static void loadWorld(Engine* engine, const fs::path& folder) {
|
||||
try {
|
||||
auto content = engine->getContent();
|
||||
auto& packs = engine->getContentPacks();
|
||||
@@ -121,7 +121,7 @@ static void loadWorld(Engine* engine, fs::path folder) {
|
||||
}
|
||||
}
|
||||
|
||||
void EngineController::openWorld(std::string name, bool confirmConvert) {
|
||||
void EngineController::openWorld(const std::string& name, bool confirmConvert) {
|
||||
auto paths = engine->getPaths();
|
||||
auto folder = paths->getWorldsFolder()/fs::u8path(name);
|
||||
if (!loadWorldContent(engine, folder)) {
|
||||
@@ -215,8 +215,8 @@ void EngineController::reopenWorld(World* world) {
|
||||
|
||||
void EngineController::reconfigPacks(
|
||||
LevelController* controller,
|
||||
std::vector<std::string> packsToAdd,
|
||||
std::vector<std::string> packsToRemove
|
||||
const std::vector<std::string>& packsToAdd,
|
||||
const std::vector<std::string>& packsToRemove
|
||||
) {
|
||||
auto content = engine->getContent();
|
||||
bool hasIndices = false;
|
||||
|
||||
Reference in New Issue
Block a user