file_sys: std::move std::shared_ptr instances in constructors where applicable

By default, a regular copy requires an atomic increment and decrement. A
move avoids this from occurring, which makes sense when the constructor
is taking the shared_ptr by value.
This commit is contained in:
Lioncash
2017-12-09 14:12:04 -05:00
parent af45f2b2de
commit 370d77f13a
5 changed files with 15 additions and 9 deletions

View File

@ -4,6 +4,7 @@
#include <cstring>
#include <memory>
#include <utility>
#include "common/common_types.h"
#include "common/logging/log.h"
#include "core/file_sys/ivfc_archive.h"
@ -13,6 +14,9 @@
namespace FileSys {
IVFCArchive::IVFCArchive(std::shared_ptr<FileUtil::IOFile> file, u64 offset, u64 size)
: romfs_file(std::move(file)), data_offset(offset), data_size(size) {}
std::string IVFCArchive::GetName() const {
return "IVFC";
}
@ -85,6 +89,9 @@ u64 IVFCArchive::GetFreeBytes() const {
////////////////////////////////////////////////////////////////////////////////////////////////////
IVFCFile::IVFCFile(std::shared_ptr<FileUtil::IOFile> file, u64 offset, u64 size)
: romfs_file(std::move(file)), data_offset(offset), data_size(size) {}
ResultVal<size_t> IVFCFile::Read(const u64 offset, const size_t length, u8* buffer) const {
LOG_TRACE(Service_FS, "called offset=%llu, length=%zu", offset, length);
romfs_file->Seek(data_offset + offset, SEEK_SET);