mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-24 07:55:38 +01:00
vfs_vector: Avoid unnecessary copies where applicable
The lambda elements should be taken by const reference here, and we can move the virtual directory passed to ReplaceFileWithSubdirectory()
This commit is contained in:
parent
a03c644aed
commit
cec9e9b811
@ -3,6 +3,7 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <utility>
|
||||||
#include "core/file_sys/vfs_vector.h"
|
#include "core/file_sys/vfs_vector.h"
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
@ -31,13 +32,15 @@ bool VectorVfsDirectory::IsReadable() const {
|
|||||||
std::string VectorVfsDirectory::GetName() const {
|
std::string VectorVfsDirectory::GetName() const {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> VectorVfsDirectory::GetParentDirectory() const {
|
std::shared_ptr<VfsDirectory> VectorVfsDirectory::GetParentDirectory() const {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static bool FindAndRemoveVectorElement(std::vector<T>& vec, std::string_view name) {
|
static bool FindAndRemoveVectorElement(std::vector<T>& vec, std::string_view name) {
|
||||||
auto iter = std::find_if(vec.begin(), vec.end(), [name](T e) { return e->GetName() == name; });
|
auto iter =
|
||||||
|
std::find_if(vec.begin(), vec.end(), [name](const T& e) { return e->GetName() == name; });
|
||||||
if (iter == vec.end())
|
if (iter == vec.end())
|
||||||
return false;
|
return false;
|
||||||
auto old_size = vec.size();
|
auto old_size = vec.size();
|
||||||
@ -77,7 +80,7 @@ void VectorVfsDirectory::AddDirectory(VirtualDir dir) {
|
|||||||
bool VectorVfsDirectory::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) {
|
bool VectorVfsDirectory::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) {
|
||||||
if (!DeleteFile(file->GetName()))
|
if (!DeleteFile(file->GetName()))
|
||||||
return false;
|
return false;
|
||||||
dirs.emplace_back(dir);
|
dirs.emplace_back(std::move(dir));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} // namespace FileSys
|
} // namespace FileSys
|
||||||
|
Loading…
Reference in New Issue
Block a user