1
0
Fork 0
forked from suyu/suyu

Merge pull request #737 from lioncash/move

filesys/loader: std::move VirtualFile instances in constructors where applicable
This commit is contained in:
bunnei 2018-07-20 09:21:15 -07:00 committed by GitHub
commit ffbd51e207
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 5 deletions

View file

@ -2,13 +2,15 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <utility>
#include "core/file_sys/vfs_offset.h" #include "core/file_sys/vfs_offset.h"
namespace FileSys { namespace FileSys {
OffsetVfsFile::OffsetVfsFile(std::shared_ptr<VfsFile> file_, size_t size_, size_t offset_, OffsetVfsFile::OffsetVfsFile(std::shared_ptr<VfsFile> file_, size_t size_, size_t offset_,
const std::string& name_) std::string name_)
: file(file_), offset(offset_), size(size_), name(name_) {} : file(std::move(file_)), offset(offset_), size(size_), name(std::move(name_)) {}
std::string OffsetVfsFile::GetName() const { std::string OffsetVfsFile::GetName() const {
return name.empty() ? file->GetName() : name; return name.empty() ? file->GetName() : name;

View file

@ -14,7 +14,7 @@ namespace FileSys {
// the size of this wrapper. // the size of this wrapper.
struct OffsetVfsFile : public VfsFile { struct OffsetVfsFile : public VfsFile {
OffsetVfsFile(std::shared_ptr<VfsFile> file, size_t size, size_t offset = 0, OffsetVfsFile(std::shared_ptr<VfsFile> file, size_t size, size_t offset = 0,
const std::string& new_name = ""); std::string new_name = "");
std::string GetName() const override; std::string GetName() const override;
size_t GetSize() const override; size_t GetSize() const override;

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <utility>
#include <vector> #include <vector>
#include "common/file_util.h" #include "common/file_util.h"
@ -21,7 +22,7 @@
namespace Loader { namespace Loader {
AppLoader_NCA::AppLoader_NCA(FileSys::VirtualFile file) : AppLoader(file) {} AppLoader_NCA::AppLoader_NCA(FileSys::VirtualFile file) : AppLoader(std::move(file)) {}
FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& file) { FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& file) {
// TODO(DarkLordZach): Assuming everything is decrypted. Add crypto support. // TODO(DarkLordZach): Assuming everything is decrypted. Add crypto support.

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <utility>
#include <vector> #include <vector>
#include "common/common_funcs.h" #include "common/common_funcs.h"
@ -48,7 +49,7 @@ struct ModHeader {
}; };
static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size."); static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size.");
AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) {} AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(std::move(file)) {}
FileType AppLoader_NRO::IdentifyType(const FileSys::VirtualFile& file) { FileType AppLoader_NRO::IdentifyType(const FileSys::VirtualFile& file) {
// Read NSO header // Read NSO header