fix: optimization: PVS-Studio warning V832
It's better to use '= default;' syntax instead of empty constructor and destructor body. Using '= default;' can help the compiler generate more optimal code. Reported by: PVS-Studio Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
parent
c858913a2f
commit
aecd0f5db9
@ -1,7 +1,6 @@
|
||||
#include "Assets.hpp"
|
||||
|
||||
Assets::~Assets() {
|
||||
}
|
||||
Assets::~Assets() = default;
|
||||
|
||||
const std::vector<TextureAnimation>& Assets::getAnimations() {
|
||||
return animations;
|
||||
|
||||
@ -68,7 +68,7 @@ class Assets {
|
||||
std::unordered_map<std::type_index, assets_map> assets;
|
||||
std::vector<assetload::setupfunc> setupFuncs;
|
||||
public:
|
||||
Assets() {}
|
||||
Assets() = default;
|
||||
Assets(const Assets&) = delete;
|
||||
~Assets();
|
||||
|
||||
|
||||
@ -266,7 +266,7 @@ speakerid_t audio::play(
|
||||
}
|
||||
auto speaker = speaker_ptr.get();
|
||||
speakerid_t id = nextId++;
|
||||
speakers.emplace(id, std::move(speaker_ptr));
|
||||
speakers.try_emplace(id, std::move(speaker_ptr));
|
||||
speaker->setPosition(position);
|
||||
speaker->setVolume(volume);
|
||||
speaker->setPitch(pitch);
|
||||
@ -295,8 +295,8 @@ speakerid_t audio::play(
|
||||
}
|
||||
auto speaker = speaker_ptr.get();
|
||||
speakerid_t id = nextId++;
|
||||
streams.emplace(id, stream);
|
||||
speakers.emplace(id, std::move(speaker_ptr));
|
||||
streams.try_emplace(id, stream);
|
||||
speakers.try_emplace(id, std::move(speaker_ptr));
|
||||
stream->bindSpeaker(id);
|
||||
|
||||
speaker->setPosition(position);
|
||||
|
||||
@ -23,7 +23,7 @@ namespace xml {
|
||||
std::string name;
|
||||
std::string text;
|
||||
public:
|
||||
Attribute() {};
|
||||
Attribute() = default;
|
||||
Attribute(std::string name, std::string text);
|
||||
|
||||
const std::string& getName() const;
|
||||
|
||||
@ -46,8 +46,7 @@ Content::Content(
|
||||
}
|
||||
}
|
||||
|
||||
Content::~Content() {
|
||||
}
|
||||
Content::~Content() = default;
|
||||
|
||||
const rigging::SkeletonConfig* Content::getSkeleton(const std::string& id) const {
|
||||
auto found = skeletons.find(id);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
#include "../objects/rigging.hpp"
|
||||
|
||||
ContentBuilder::~ContentBuilder() {}
|
||||
ContentBuilder::~ContentBuilder() = default;
|
||||
|
||||
void ContentBuilder::add(std::unique_ptr<ContentPackRuntime> pack) {
|
||||
packs[pack->getId()] = std::move(pack);
|
||||
|
||||
@ -142,5 +142,4 @@ ContentPackRuntime::ContentPackRuntime(
|
||||
{
|
||||
}
|
||||
|
||||
ContentPackRuntime::~ContentPackRuntime() {
|
||||
}
|
||||
ContentPackRuntime::~ContentPackRuntime() = default;
|
||||
|
||||
@ -5,8 +5,7 @@
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
|
||||
PacksManager::PacksManager() {
|
||||
}
|
||||
PacksManager::PacksManager() = default;
|
||||
|
||||
void PacksManager::setSources(std::vector<fs::path> sources) {
|
||||
this->sources = sources;
|
||||
@ -19,7 +18,7 @@ void PacksManager::scan() {
|
||||
for (auto& folder : sources) {
|
||||
ContentPack::scanFolder(folder, packsList);
|
||||
for (auto& pack : packsList) {
|
||||
packs.emplace(pack.id, pack);
|
||||
packs.try_emplace(pack.id, pack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ namespace dynamic {
|
||||
public:
|
||||
std::vector<Value> values;
|
||||
|
||||
List() {}
|
||||
List() = default;
|
||||
List(std::vector<Value> values) : values(std::move(values)) {}
|
||||
|
||||
std::string str(size_t index) const;
|
||||
@ -79,7 +79,7 @@ namespace dynamic {
|
||||
public:
|
||||
std::unordered_map<std::string, Value> values;
|
||||
|
||||
Map() {}
|
||||
Map() = default;
|
||||
Map(std::unordered_map<std::string, Value> values)
|
||||
: values(std::move(values)) {};
|
||||
|
||||
|
||||
@ -47,8 +47,7 @@ WorldFiles::WorldFiles(const fs::path& directory, const DebugSettings& settings)
|
||||
regions.doWriteLights = doWriteLights;
|
||||
}
|
||||
|
||||
WorldFiles::~WorldFiles() {
|
||||
}
|
||||
WorldFiles::~WorldFiles() = default;
|
||||
|
||||
void WorldFiles::createDirectories() {
|
||||
fs::create_directories(directory / fs::path("data"));
|
||||
|
||||
@ -56,8 +56,7 @@ WorldRegion::WorldRegion()
|
||||
sizes(std::make_unique<uint32_t[]>(REGION_CHUNKS_COUNT))
|
||||
{}
|
||||
|
||||
WorldRegion::~WorldRegion() {
|
||||
}
|
||||
WorldRegion::~WorldRegion() = default;
|
||||
|
||||
void WorldRegion::setUnsaved(bool unsaved) {
|
||||
this->unsaved = unsaved;
|
||||
@ -98,8 +97,7 @@ WorldRegions::WorldRegions(const fs::path& directory) : directory(directory) {
|
||||
layers[REGION_LAYER_ENTITIES].folder = directory/fs::path("entities");
|
||||
}
|
||||
|
||||
WorldRegions::~WorldRegions() {
|
||||
}
|
||||
WorldRegions::~WorldRegions() = default;
|
||||
|
||||
WorldRegion* WorldRegions::getRegion(int x, int z, int layer) {
|
||||
RegionsLayer& regions = layers[layer];
|
||||
|
||||
@ -38,8 +38,7 @@ ContentGfxCache::ContentGfxCache(const Content* content, Assets* assets) : conte
|
||||
}
|
||||
}
|
||||
|
||||
ContentGfxCache::~ContentGfxCache() {
|
||||
}
|
||||
ContentGfxCache::~ContentGfxCache() = default;
|
||||
|
||||
const Content* ContentGfxCache::getContent() const {
|
||||
return content;
|
||||
|
||||
@ -81,8 +81,7 @@ LevelFrontend::LevelFrontend(
|
||||
);
|
||||
}
|
||||
|
||||
LevelFrontend::~LevelFrontend() {
|
||||
}
|
||||
LevelFrontend::~LevelFrontend() = default;
|
||||
|
||||
Level* LevelFrontend::getLevel() const {
|
||||
return level;
|
||||
|
||||
@ -19,8 +19,7 @@ Atlas::Atlas(
|
||||
}
|
||||
}
|
||||
|
||||
Atlas::~Atlas() {
|
||||
}
|
||||
Atlas::~Atlas() = default;
|
||||
|
||||
void Atlas::prepare() {
|
||||
texture = Texture::from(image.get());
|
||||
|
||||
@ -47,7 +47,7 @@ class AtlasBuilder {
|
||||
std::vector<atlasentry> entries;
|
||||
std::set<std::string> names;
|
||||
public:
|
||||
AtlasBuilder() {}
|
||||
AtlasBuilder() = default;
|
||||
void add(const std::string& name, std::unique_ptr<ImageData> image);
|
||||
bool has(const std::string& name) const;
|
||||
const std::set<std::string>& getNames() { return names; };
|
||||
|
||||
@ -12,8 +12,7 @@ Font::Font(std::vector<std::unique_ptr<Texture>> pages, int lineHeight, int yoff
|
||||
: lineHeight(lineHeight), yoffset(yoffset), pages(std::move(pages)) {
|
||||
}
|
||||
|
||||
Font::~Font(){
|
||||
}
|
||||
Font::~Font() = default;
|
||||
|
||||
int Font::getYOffset() const {
|
||||
return yoffset;
|
||||
|
||||
@ -41,8 +41,7 @@ ImageData::ImageData(ImageFormat format, uint width, uint height, const ubyte* d
|
||||
std::memcpy(this->data.get(), data, width * height * pixsize);
|
||||
}
|
||||
|
||||
ImageData::~ImageData() {
|
||||
}
|
||||
ImageData::~ImageData() = default;
|
||||
|
||||
void ImageData::flipX() {
|
||||
switch (format) {
|
||||
|
||||
@ -18,8 +18,7 @@ PostProcessing::PostProcessing() {
|
||||
quadMesh = std::make_unique<Mesh>(vertices, 6, attrs);
|
||||
}
|
||||
|
||||
PostProcessing::~PostProcessing() {
|
||||
}
|
||||
PostProcessing::~PostProcessing() = default;
|
||||
|
||||
void PostProcessing::use(DrawContext& context) {
|
||||
const auto& vp = context.getViewport();
|
||||
|
||||
@ -32,7 +32,7 @@ uint Shader::getUniformLocation(const std::string& name) {
|
||||
auto found = uniformLocations.find(name);
|
||||
if (found == uniformLocations.end()) {
|
||||
uint location = glGetUniformLocation(id, name.c_str());
|
||||
uniformLocations.emplace(name, location);
|
||||
uniformLocations.try_emplace(name, location);
|
||||
return location;
|
||||
}
|
||||
return found->second;
|
||||
|
||||
@ -22,7 +22,7 @@ struct Frame {
|
||||
class TextureAnimation {
|
||||
public:
|
||||
TextureAnimation(Texture* srcTex, Texture* dstTex) : srcTexture(srcTex), dstTexture(dstTex) {};
|
||||
~TextureAnimation() {};
|
||||
~TextureAnimation() = default;
|
||||
|
||||
void addFrame(const Frame& frame) { frames.emplace_back(frame); };
|
||||
|
||||
|
||||
@ -64,8 +64,7 @@ ModelBatch::ModelBatch(size_t capacity, Assets* assets, Chunks* chunks)
|
||||
blank = Texture::from(&image);
|
||||
}
|
||||
|
||||
ModelBatch::~ModelBatch() {
|
||||
}
|
||||
ModelBatch::~ModelBatch() = default;
|
||||
|
||||
void ModelBatch::draw(const model::Mesh& mesh, const glm::mat4& matrix,
|
||||
const glm::mat3& rotation, glm::vec3 tint,
|
||||
|
||||
@ -55,8 +55,7 @@ Skybox::Skybox(uint size, Shader* shader)
|
||||
});
|
||||
}
|
||||
|
||||
Skybox::~Skybox() {
|
||||
}
|
||||
Skybox::~Skybox() = default;
|
||||
|
||||
void Skybox::drawBackground(Camera* camera, Assets* assets, int width, int height) {
|
||||
auto backShader = assets->get<Shader>("background");
|
||||
|
||||
@ -75,8 +75,7 @@ WorldRenderer::WorldRenderer(Engine* engine, LevelFrontend* frontend, Player* pl
|
||||
);
|
||||
}
|
||||
|
||||
WorldRenderer::~WorldRenderer() {
|
||||
}
|
||||
WorldRenderer::~WorldRenderer() = default;
|
||||
|
||||
bool WorldRenderer::drawChunk(
|
||||
size_t index,
|
||||
|
||||
@ -44,8 +44,7 @@ GUI::GUI() {
|
||||
container->add(tooltip);
|
||||
}
|
||||
|
||||
GUI::~GUI() {
|
||||
}
|
||||
GUI::~GUI() = default;
|
||||
|
||||
std::shared_ptr<Menu> GUI::getMenu() {
|
||||
return menu;
|
||||
|
||||
@ -8,8 +8,7 @@
|
||||
Inventories::Inventories(Level& level) : level(level) {
|
||||
}
|
||||
|
||||
Inventories::~Inventories() {
|
||||
}
|
||||
Inventories::~Inventories() = default;
|
||||
|
||||
std::shared_ptr<Inventory> Inventories::create(size_t size) {
|
||||
int64_t id = level.getWorld()->getNextInventoryId();
|
||||
|
||||
@ -20,8 +20,7 @@ Lighting::Lighting(const Content* content, Chunks* chunks)
|
||||
solverS = std::make_unique<LightSolver>(indices, chunks, 3);
|
||||
}
|
||||
|
||||
Lighting::~Lighting(){
|
||||
}
|
||||
Lighting::~Lighting() = default;
|
||||
|
||||
void Lighting::clear(){
|
||||
for (size_t index = 0; index < chunks->volume; index++){
|
||||
|
||||
@ -30,8 +30,7 @@ ChunksController::ChunksController(Level* level, uint padding)
|
||||
generator(WorldGenerators::createGenerator(level->getWorld()->getGenerator(), level->content)) {
|
||||
}
|
||||
|
||||
ChunksController::~ChunksController(){
|
||||
}
|
||||
ChunksController::~ChunksController() = default;
|
||||
|
||||
void ChunksController::update(int64_t maxDuration) {
|
||||
int64_t mcstotal = 0;
|
||||
|
||||
@ -55,7 +55,7 @@ namespace cmd {
|
||||
std::string description;
|
||||
executor_func executor;
|
||||
public:
|
||||
Command() {}
|
||||
Command() = default;
|
||||
|
||||
Command(
|
||||
std::string name,
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
class Frustum {
|
||||
public:
|
||||
Frustum() {};
|
||||
Frustum() = default;
|
||||
|
||||
void update(glm::mat4 projview);
|
||||
bool isBoxVisible(const glm::vec3& minp, const glm::vec3& maxp) const;
|
||||
|
||||
@ -21,7 +21,7 @@ class AABBFaces {
|
||||
public:
|
||||
std::array<std::pair<rayvec3, rayvec2>, AABBFACES_COUNT> faces; // every face is min-point and opposite corner point
|
||||
|
||||
AABBFaces(){};
|
||||
AABBFaces() = default;
|
||||
AABBFaces(const rayvec3& parentBoxPos, const AABB& parentBox);
|
||||
};
|
||||
|
||||
|
||||
@ -28,8 +28,8 @@ struct ThreadPoolResult {
|
||||
template<class T, class R>
|
||||
class Worker {
|
||||
public:
|
||||
Worker() {}
|
||||
virtual ~Worker() {}
|
||||
Worker() = default;
|
||||
virtual ~Worker() = default;
|
||||
virtual R operator()(const std::shared_ptr<T>&) = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -142,7 +142,7 @@ struct Binding {
|
||||
bool state = false;
|
||||
bool justChange = false;
|
||||
|
||||
Binding(){}
|
||||
Binding() = default;
|
||||
Binding(inputtype type, int code) : type(type), code(code) {}
|
||||
|
||||
bool active() const {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user