Add std::move to the resource managers

This commit is contained in:
Riyyi
2021-02-14 00:21:33 +01:00
parent 6103854503
commit 4467d0d40a
4 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -122,7 +122,7 @@ namespace Inferno {
void FontManager::add(const std::string& name, const std::shared_ptr<Font>& font)
{
// Construct (key, value) pair and insert it into the unordered_map
m_fontList.emplace(name, font);
m_fontList.emplace(std::move(name), std::move(font));
}
std::shared_ptr<Font> FontManager::load(const std::string& name)
+6 -6
View File
@@ -30,23 +30,23 @@ class Texture;
Font(const std::string& name);
virtual ~Font() {}
inline std::string name() const { return m_name; }
inline uint32_t size() const { return m_size; }
inline const std::shared_ptr<Texture>& texture() const { return m_texture; }
inline const std::shared_ptr<Character>& get(unsigned char c) const { return m_characterList.at(c); }
inline const std::shared_ptr<Character>& operator[](unsigned char c) const { return m_characterList.at(c); }
inline std::string name() const { return m_name; }
inline const std::shared_ptr<Texture>& texture() const { return m_texture; }
private:
void parseFont(const std::string& font);
const std::string findAction(const std::string& line);
const std::vector<std::string> findColumns(const std::string& line);
const std::string findValue(const std::string& key, const std::vector<std::string>& columns);
uint32_t m_size;
std::unordered_map<unsigned char, std::shared_ptr<Character>> m_characterList;
std::string m_name;
uint32_t m_size;
std::shared_ptr<Texture> m_texture;
std::unordered_map<unsigned char, std::shared_ptr<Character>> m_characterList;
};
// -----------------------------------------
@@ -62,7 +62,7 @@ class Texture;
bool exists(const std::string& name);
void remove(const std::string& name);
void remove(const std::shared_ptr<Font>& shader);
void remove(const std::shared_ptr<Font>& font);
static inline FontManager& the() { return *s_instance; }
+1 -1
View File
@@ -212,7 +212,7 @@ namespace Inferno {
void ShaderManager::add(const std::string& name, const std::shared_ptr<Shader>& shader)
{
// Construct (key, value) pair and insert it into the unordered_map
m_shaderList.emplace(name, shader);
m_shaderList.emplace(std::move(name), std::move(shader));
}
std::shared_ptr<Shader> ShaderManager::load(const std::string& name)
+1 -1
View File
@@ -122,7 +122,7 @@ namespace Inferno {
void TextureManager::add(const std::string& path, const std::shared_ptr<Texture>& texture)
{
// Construct (key, value) pair and insert it into the unordered_map
m_textureList.emplace(path, texture);
m_textureList.emplace(std::move(path), std::move(texture));
}
std::shared_ptr<Texture> TextureManager::load(const std::string& path)