Browse Source

Omit copy constructors for strings in constructors

master
Riyyi 3 years ago
parent
commit
e044397e88
  1. 5
      inferno/src/inferno/component/luascriptcomponent.h
  2. 3
      inferno/src/inferno/component/tagcomponent.h
  3. 6
      inferno/src/inferno/render/font.cpp
  4. 2
      inferno/src/inferno/render/gltf.cpp
  5. 6
      inferno/src/inferno/render/shader.cpp
  6. 4
      inferno/src/inferno/render/texture.cpp

5
inferno/src/inferno/component/luascriptcomponent.h

@ -1,7 +1,8 @@
#ifndef LUA_SCRIPT_COMPONENT_H
#define LUA_SCRIPT_COMPONENT_H
#include <string> // std::string
#include <string> // std::string
#include <utility> // std::move
namespace Inferno {
@ -14,7 +15,7 @@ namespace Inferno {
// Dont allow manually setting instance during construction
LuaScriptComponent() {}
LuaScriptComponent(const std::string& path)
: path(path) {}
: path(std::move(path)) {}
};
}

3
inferno/src/inferno/component/tagcomponent.h

@ -2,6 +2,7 @@
#define TAG_COMPONENT_H
#include <string> // std::string
#include <utility> // std::move
namespace Inferno {
@ -10,7 +11,7 @@ namespace Inferno {
TagComponent() = default;
TagComponent(const std::string& tag)
: tag(tag) {}
: tag(std::move(tag)) {}
operator const std::string&() const { return tag; }
};

6
inferno/src/inferno/render/font.cpp

@ -1,5 +1,6 @@
#include <limits> // std::numeric_limits
#include <string> // std::getline, std::stoi
#include <limits> // std::numeric_limits
#include <string> // std::getline, std::stoi
#include <utility> // std::move
#include "inferno/assert.h"
#include "inferno/io/file.h"
@ -10,6 +11,7 @@
namespace Inferno {
Font::Font(const std::string& name)
: m_name(std::move(name))
{
std::string path = name + ".fnt";
std::string image = name + ".png";

2
inferno/src/inferno/render/gltf.cpp

@ -13,7 +13,7 @@
namespace Inferno {
Gltf::Gltf(const std::string& path)
: m_path(path)
: m_path(std::move(path))
{
auto gltf = GltfFile::read(path);
ASSERT(gltf.first, "Gltf model invalid JSON content '{}'", path);

6
inferno/src/inferno/render/shader.cpp

@ -1,4 +1,5 @@
#include <vector> // std::vector
#include <utility> // std::move
#include <vector> // std::vector
#include "glad/glad.h"
#include "glm/gtc/type_ptr.hpp" // glm::value_ptr
@ -12,7 +13,8 @@
namespace Inferno {
Shader::Shader(const std::string& name)
: m_id(0)
: m_name(std::move(name)),
m_id(0)
{
// Get file contents
std::string vertexSrc = File::read(name + ".vert");

4
inferno/src/inferno/render/texture.cpp

@ -1,5 +1,6 @@
#include <climits> // UINT_MAX
#include <memory>
#include <memory> // std::shared_ptr
#include <utility> // std::move
#include "glad/glad.h"
#define STB_IMAGE_IMPLEMENTATION
@ -11,6 +12,7 @@
namespace Inferno {
Texture::Texture(const std::string& path)
: m_path(std::move(path))
{
int width;
int height;

Loading…
Cancel
Save