From 4467d0d40ae47de018f1b01842d546f2523e3657 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sun, 14 Feb 2021 00:21:33 +0100 Subject: [PATCH] Add std::move to the resource managers --- inferno/src/inferno/render/font.cpp | 2 +- inferno/src/inferno/render/font.h | 12 ++++++------ inferno/src/inferno/render/shader.cpp | 2 +- inferno/src/inferno/render/texture.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/inferno/src/inferno/render/font.cpp b/inferno/src/inferno/render/font.cpp index e34f272..8013c1b 100644 --- a/inferno/src/inferno/render/font.cpp +++ b/inferno/src/inferno/render/font.cpp @@ -122,7 +122,7 @@ namespace Inferno { void FontManager::add(const std::string& name, const std::shared_ptr& 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 FontManager::load(const std::string& name) diff --git a/inferno/src/inferno/render/font.h b/inferno/src/inferno/render/font.h index 5e67b41..49ecffd 100644 --- a/inferno/src/inferno/render/font.h +++ b/inferno/src/inferno/render/font.h @@ -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() const { return m_texture; } + inline const std::shared_ptr& get(unsigned char c) const { return m_characterList.at(c); } inline const std::shared_ptr& operator[](unsigned char c) const { return m_characterList.at(c); } - inline std::string name() const { return m_name; } - inline const std::shared_ptr& texture() const { return m_texture; } - private: void parseFont(const std::string& font); const std::string findAction(const std::string& line); const std::vector findColumns(const std::string& line); const std::string findValue(const std::string& key, const std::vector& columns); - uint32_t m_size; - std::unordered_map> m_characterList; std::string m_name; + uint32_t m_size; std::shared_ptr m_texture; + std::unordered_map> 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& shader); + void remove(const std::shared_ptr& font); static inline FontManager& the() { return *s_instance; } diff --git a/inferno/src/inferno/render/shader.cpp b/inferno/src/inferno/render/shader.cpp index 1d87c1b..816363f 100644 --- a/inferno/src/inferno/render/shader.cpp +++ b/inferno/src/inferno/render/shader.cpp @@ -212,7 +212,7 @@ namespace Inferno { void ShaderManager::add(const std::string& name, const std::shared_ptr& 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 ShaderManager::load(const std::string& name) diff --git a/inferno/src/inferno/render/texture.cpp b/inferno/src/inferno/render/texture.cpp index d2157a2..6d12e51 100644 --- a/inferno/src/inferno/render/texture.cpp +++ b/inferno/src/inferno/render/texture.cpp @@ -122,7 +122,7 @@ namespace Inferno { void TextureManager::add(const std::string& path, const std::shared_ptr& 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 TextureManager::load(const std::string& path)