Browse Source

Add std::move to the resource managers

master
Riyyi 3 years ago
parent
commit
4467d0d40a
  1. 2
      inferno/src/inferno/render/font.cpp
  2. 12
      inferno/src/inferno/render/font.h
  3. 2
      inferno/src/inferno/render/shader.cpp
  4. 2
      inferno/src/inferno/render/texture.cpp

2
inferno/src/inferno/render/font.cpp

@ -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)

12
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>& 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; }

2
inferno/src/inferno/render/shader.cpp

@ -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)

2
inferno/src/inferno/render/texture.cpp

@ -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)

Loading…
Cancel
Save