From 0b566f43a1f49121c0e4a9950a71319d60adccef Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 18 Jul 2018 23:12:14 -0400 Subject: content_archive: std::move VirtualFile in NCA's constructor Gets rid of unnecessary atomic reference count incrementing and decrementing. --- src/core/file_sys/content_archive.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index 6cfef774d..d6b20c047 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp @@ -2,6 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include + #include "common/logging/log.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/vfs_offset.h" @@ -61,7 +64,7 @@ struct RomFSSuperblock { }; static_assert(sizeof(RomFSSuperblock) == 0xE8, "RomFSSuperblock has incorrect size."); -NCA::NCA(VirtualFile file_) : file(file_) { +NCA::NCA(VirtualFile file_) : file(std::move(file_)) { if (sizeof(NCAHeader) != file->ReadObject(&header)) LOG_CRITICAL(Loader, "File reader errored out during header read."); -- cgit v1.2.3 From 87a9bb392b9cd14c646667e17b638931062a1b73 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 18 Jul 2018 23:13:57 -0400 Subject: content_archive: Add missing standard includes --- src/core/file_sys/content_archive.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h index 129a70b97..d4517d20e 100644 --- a/src/core/file_sys/content_archive.h +++ b/src/core/file_sys/content_archive.h @@ -4,6 +4,11 @@ #pragma once +#include +#include +#include +#include + #include "common/common_funcs.h" #include "common/common_types.h" #include "common/swap.h" -- cgit v1.2.3 From 4790bb907db5ff53b8bd62cc93c65fc2749b1fc4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 18 Jul 2018 23:16:10 -0400 Subject: content_archive: Make IsDirectoryExeFS() take a shared_ptr as a const reference There's no need to take this by value when it's possible to avoid unnecessary copies entirely like this. --- src/core/file_sys/content_archive.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h index d4517d20e..0b8b9db61 100644 --- a/src/core/file_sys/content_archive.h +++ b/src/core/file_sys/content_archive.h @@ -53,7 +53,7 @@ struct NCAHeader { }; static_assert(sizeof(NCAHeader) == 0x400, "NCAHeader has incorrect size."); -inline bool IsDirectoryExeFS(std::shared_ptr pfs) { +inline bool IsDirectoryExeFS(const std::shared_ptr& pfs) { // According to switchbrew, an exefs must only contain these two files: return pfs->GetFile("main") != nullptr && pfs->GetFile("main.npdm") != nullptr; } -- cgit v1.2.3