Omit copy constructors for strings in constructors

This commit is contained in:
Riyyi
2021-02-10 14:36:19 +01:00
parent 858a2bd0d4
commit e044397e88
6 changed files with 17 additions and 9 deletions
@@ -2,6 +2,7 @@
#define LUA_SCRIPT_COMPONENT_H
#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)) {}
};
}
+2 -1
View File
@@ -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; }
};
+2
View File
@@ -1,5 +1,6 @@
#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";
+1 -1
View File
@@ -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);
+3 -1
View File
@@ -1,3 +1,4 @@
#include <utility> // std::move
#include <vector> // std::vector
#include "glad/glad.h"
@@ -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");
+3 -1
View File
@@ -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;