Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #8579 from jordan-woyak/rvalue-cleanups
Common/Core: Minor rvalue reference related cleanups.
  • Loading branch information
Tilka committed Jan 25, 2020
2 parents 14ebdf0 + 732032c commit a632bc7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 46 deletions.
8 changes: 1 addition & 7 deletions Source/Core/Common/IniFile.cpp
Expand Up @@ -185,13 +185,7 @@ bool IniFile::Exists(std::string_view section_name, std::string_view key) const
return section->Exists(key);
}

void IniFile::SetLines(std::string_view section_name, const std::vector<std::string>& lines)
{
Section* section = GetOrCreateSection(section_name);
section->SetLines(lines);
}

void IniFile::SetLines(std::string_view section_name, std::vector<std::string>&& lines)
void IniFile::SetLines(std::string_view section_name, std::vector<std::string> lines)
{
Section* section = GetOrCreateSection(section_name);
section->SetLines(std::move(lines));
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Common/IniFile.h
Expand Up @@ -143,8 +143,7 @@ class IniFile

bool GetKeys(std::string_view section_name, std::vector<std::string>* keys) const;

void SetLines(std::string_view section_name, const std::vector<std::string>& lines);
void SetLines(std::string_view section_name, std::vector<std::string>&& lines);
void SetLines(std::string_view section_name, std::vector<std::string> lines);
bool GetLines(std::string_view section_name, std::vector<std::string>* lines,
bool remove_comments = true) const;

Expand Down
25 changes: 4 additions & 21 deletions Source/Core/Core/IOS/ES/Formats.cpp
Expand Up @@ -79,11 +79,7 @@ bool operator!=(const Content& lhs, const Content& rhs)
return !operator==(lhs, rhs);
}

SignedBlobReader::SignedBlobReader(const std::vector<u8>& bytes) : m_bytes(bytes)
{
}

SignedBlobReader::SignedBlobReader(std::vector<u8>&& bytes) : m_bytes(std::move(bytes))
SignedBlobReader::SignedBlobReader(std::vector<u8> bytes) : m_bytes(std::move(bytes))
{
}

Expand All @@ -92,12 +88,7 @@ const std::vector<u8>& SignedBlobReader::GetBytes() const
return m_bytes;
}

void SignedBlobReader::SetBytes(const std::vector<u8>& bytes)
{
m_bytes = bytes;
}

void SignedBlobReader::SetBytes(std::vector<u8>&& bytes)
void SignedBlobReader::SetBytes(std::vector<u8> bytes)
{
m_bytes = std::move(bytes);
}
Expand Down Expand Up @@ -213,11 +204,7 @@ bool IsValidTMDSize(size_t size)
return size <= 0x49e4;
}

TMDReader::TMDReader(const std::vector<u8>& bytes) : SignedBlobReader(bytes)
{
}

TMDReader::TMDReader(std::vector<u8>&& bytes) : SignedBlobReader(std::move(bytes))
TMDReader::TMDReader(std::vector<u8> bytes) : SignedBlobReader(std::move(bytes))
{
}

Expand Down Expand Up @@ -376,11 +363,7 @@ bool TMDReader::FindContentById(u32 id, Content* content) const
return false;
}

TicketReader::TicketReader(const std::vector<u8>& bytes) : SignedBlobReader(bytes)
{
}

TicketReader::TicketReader(std::vector<u8>&& bytes) : SignedBlobReader(std::move(bytes))
TicketReader::TicketReader(std::vector<u8> bytes) : SignedBlobReader(std::move(bytes))
{
}

Expand Down
12 changes: 4 additions & 8 deletions Source/Core/Core/IOS/ES/Formats.h
Expand Up @@ -155,12 +155,10 @@ class SignedBlobReader
{
public:
SignedBlobReader() = default;
explicit SignedBlobReader(const std::vector<u8>& bytes);
explicit SignedBlobReader(std::vector<u8>&& bytes);
explicit SignedBlobReader(std::vector<u8> bytes);

const std::vector<u8>& GetBytes() const;
void SetBytes(const std::vector<u8>& bytes);
void SetBytes(std::vector<u8>&& bytes);
void SetBytes(std::vector<u8> bytes);

/// Get the SHA1 hash for this signed blob (starting at the issuer).
std::array<u8, 20> GetSha1() const;
Expand All @@ -187,8 +185,7 @@ class TMDReader final : public SignedBlobReader
{
public:
TMDReader() = default;
explicit TMDReader(const std::vector<u8>& bytes);
explicit TMDReader(std::vector<u8>&& bytes);
explicit TMDReader(std::vector<u8> bytes);

bool IsValid() const;

Expand Down Expand Up @@ -224,8 +221,7 @@ class TicketReader final : public SignedBlobReader
{
public:
TicketReader() = default;
explicit TicketReader(const std::vector<u8>& bytes);
explicit TicketReader(std::vector<u8>&& bytes);
explicit TicketReader(std::vector<u8> bytes);

bool IsValid() const;

Expand Down
7 changes: 1 addition & 6 deletions Source/Core/Core/SysConf.cpp
Expand Up @@ -217,12 +217,7 @@ SysConf::Entry::Entry(Type type_, const std::string& name_) : type(type_), name(
bytes.resize(GetNonArrayEntrySize(type));
}

SysConf::Entry::Entry(Type type_, const std::string& name_, const std::vector<u8>& bytes_)
: type(type_), name(name_), bytes(bytes_)
{
}

SysConf::Entry::Entry(Type type_, const std::string& name_, std::vector<u8>&& bytes_)
SysConf::Entry::Entry(Type type_, const std::string& name_, std::vector<u8> bytes_)
: type(type_), name(name_), bytes(std::move(bytes_))
{
}
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Core/SysConf.h
Expand Up @@ -47,8 +47,7 @@ class SysConf final
};

Entry(Type type_, const std::string& name_);
Entry(Type type_, const std::string& name_, const std::vector<u8>& bytes_);
Entry(Type type_, const std::string& name_, std::vector<u8>&& bytes_);
Entry(Type type_, const std::string& name_, std::vector<u8> bytes_);

// Intended for use with the non array types.
template <typename T>
Expand Down

0 comments on commit a632bc7

Please sign in to comment.