forked from suyu/suyu
vfs: Make WriteBytes() overload taking a std::vector pass the std::vector by const reference
Given the data is intended to be directly written, there's no need to take the std::vector by value and copy the data.
This commit is contained in:
parent
dd09439fee
commit
894b0de0f2
4 changed files with 4 additions and 4 deletions
|
@ -42,7 +42,7 @@ bool VfsFile::WriteByte(u8 data, size_t offset) {
|
||||||
return Write(&data, 1, offset) == 1;
|
return Write(&data, 1, offset) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t VfsFile::WriteBytes(std::vector<u8> data, size_t offset) {
|
size_t VfsFile::WriteBytes(const std::vector<u8>& data, size_t offset) {
|
||||||
return Write(data.data(), data.size(), offset);
|
return Write(data.data(), data.size(), offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ struct VfsFile : NonCopyable {
|
||||||
virtual bool WriteByte(u8 data, size_t offset = 0);
|
virtual bool WriteByte(u8 data, size_t offset = 0);
|
||||||
// Writes a vector of bytes to offset in file and returns the number of bytes successfully
|
// Writes a vector of bytes to offset in file and returns the number of bytes successfully
|
||||||
// written.
|
// written.
|
||||||
virtual size_t WriteBytes(std::vector<u8> data, size_t offset = 0);
|
virtual size_t WriteBytes(const std::vector<u8>& data, size_t offset = 0);
|
||||||
|
|
||||||
// Writes an array of type T, size number_elements to offset in file.
|
// Writes an array of type T, size number_elements to offset in file.
|
||||||
// Returns the number of bytes (sizeof(T)*number_elements) written successfully.
|
// Returns the number of bytes (sizeof(T)*number_elements) written successfully.
|
||||||
|
|
|
@ -75,7 +75,7 @@ bool OffsetVfsFile::WriteByte(u8 data, size_t r_offset) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t OffsetVfsFile::WriteBytes(std::vector<u8> data, size_t r_offset) {
|
size_t OffsetVfsFile::WriteBytes(const std::vector<u8>& data, size_t r_offset) {
|
||||||
return file->Write(data.data(), TrimToFit(data.size(), r_offset), offset + r_offset);
|
return file->Write(data.data(), TrimToFit(data.size(), r_offset), offset + r_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct OffsetVfsFile : public VfsFile {
|
||||||
std::vector<u8> ReadBytes(size_t size, size_t offset) const override;
|
std::vector<u8> ReadBytes(size_t size, size_t offset) const override;
|
||||||
std::vector<u8> ReadAllBytes() const override;
|
std::vector<u8> ReadAllBytes() const override;
|
||||||
bool WriteByte(u8 data, size_t offset) override;
|
bool WriteByte(u8 data, size_t offset) override;
|
||||||
size_t WriteBytes(std::vector<u8> data, size_t offset) override;
|
size_t WriteBytes(const std::vector<u8>& data, size_t offset) override;
|
||||||
|
|
||||||
bool Rename(const std::string& name) override;
|
bool Rename(const std::string& name) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue