From 46d74a7760e58ec36d59ab525ced11d884bcb267 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 22 Mar 2017 18:19:53 -0400 Subject: [PATCH] IniFile: Make Section's string constructor instances take strings by value As the name is immediately stored into a class member, a move here is a better choice. This also moves the constructor implementations into the cpp file to avoid an otherwise unnecessary inclusion in the header. This is also likely a better choice as Section contains several non-trivial members, so this would avoid potentially inlining a bunch of setup and teardown code related to them as a side-benefit. --- Source/Core/Common/IniFile.cpp | 6 ++++++ Source/Core/Common/IniFile.h | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp index 50752aabc1..cf2c89e0f3 100644 --- a/Source/Core/Common/IniFile.cpp +++ b/Source/Core/Common/IniFile.cpp @@ -39,6 +39,12 @@ void IniFile::ParseLine(const std::string& line, std::string* keyOut, std::strin const std::string& IniFile::NULL_STRING = ""; +IniFile::Section::Section() = default; + +IniFile::Section::Section(std::string name_) : name{std::move(name_)} +{ +} + void IniFile::Section::Set(const std::string& key, const std::string& newValue) { auto it = values.find(key); diff --git a/Source/Core/Common/IniFile.h b/Source/Core/Common/IniFile.h index e8902f468a..72f2317a91 100644 --- a/Source/Core/Common/IniFile.h +++ b/Source/Core/Common/IniFile.h @@ -29,8 +29,8 @@ public: friend class IniFile; public: - Section() {} - explicit Section(const std::string& name_) : name(name_) {} + Section(); + explicit Section(std::string name_); bool Exists(const std::string& key) const; bool Delete(const std::string& key);