fix: optimization: PVS-Studio warning V807
Created references to avoid using repeated expressions, improving performance across multiple instances. Reported by: PVS-Studio Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
parent
52905ff27b
commit
c858913a2f
@ -176,9 +176,10 @@ void ContentLoader::loadBlock(Block& def, const std::string& name, const fs::pat
|
|||||||
def.hitboxes.resize(boxarr->size());
|
def.hitboxes.resize(boxarr->size());
|
||||||
for (uint i = 0; i < boxarr->size(); i++) {
|
for (uint i = 0; i < boxarr->size(); i++) {
|
||||||
auto box = boxarr->list(i);
|
auto box = boxarr->list(i);
|
||||||
def.hitboxes[i].a = glm::vec3(box->num(0), box->num(1), box->num(2));
|
auto& hitboxesIndex = def.hitboxes[i];
|
||||||
def.hitboxes[i].b = glm::vec3(box->num(3), box->num(4), box->num(5));
|
hitboxesIndex.a = glm::vec3(box->num(0), box->num(1), box->num(2));
|
||||||
def.hitboxes[i].b += def.hitboxes[i].a;
|
hitboxesIndex.b = glm::vec3(box->num(3), box->num(4), box->num(5));
|
||||||
|
hitboxesIndex.b += hitboxesIndex.a;
|
||||||
}
|
}
|
||||||
} else if ((boxarr = root->list("hitbox"))){
|
} else if ((boxarr = root->list("hitbox"))){
|
||||||
AABB aabb;
|
AABB aabb;
|
||||||
|
|||||||
@ -73,11 +73,12 @@ std::shared_ptr<Task> WorldConverter::startTask(
|
|||||||
[=](){return std::make_shared<ConverterWorker>(converter);},
|
[=](){return std::make_shared<ConverterWorker>(converter);},
|
||||||
[=](int&) {}
|
[=](int&) {}
|
||||||
);
|
);
|
||||||
while (!converter->tasks.empty()) {
|
auto& converterTasks = converter->tasks;
|
||||||
const convert_task& task = converter->tasks.front();
|
while (!converterTasks.empty()) {
|
||||||
|
const convert_task& task = converterTasks.front();
|
||||||
auto ptr = std::make_shared<convert_task>(task);
|
auto ptr = std::make_shared<convert_task>(task);
|
||||||
pool->enqueueJob(ptr);
|
pool->enqueueJob(ptr);
|
||||||
converter->tasks.pop();
|
converterTasks.pop();
|
||||||
}
|
}
|
||||||
pool->setOnComplete([=]() {
|
pool->setOnComplete([=]() {
|
||||||
converter->write();
|
converter->write();
|
||||||
|
|||||||
@ -113,21 +113,22 @@ bool ChunksController::buildLights(const std::shared_ptr<Chunk>& chunk) {
|
|||||||
void ChunksController::createChunk(int x, int z) {
|
void ChunksController::createChunk(int x, int z) {
|
||||||
auto chunk = level->chunksStorage->create(x, z);
|
auto chunk = level->chunksStorage->create(x, z);
|
||||||
chunks->putChunk(chunk);
|
chunks->putChunk(chunk);
|
||||||
|
auto& chunkFlags = chunk->flags;
|
||||||
|
|
||||||
if (!chunk->flags.loaded) {
|
if (!chunkFlags.loaded) {
|
||||||
generator->generate(
|
generator->generate(
|
||||||
chunk->voxels, x, z,
|
chunk->voxels, x, z,
|
||||||
level->getWorld()->getSeed()
|
level->getWorld()->getSeed()
|
||||||
);
|
);
|
||||||
chunk->flags.unsaved = true;
|
chunkFlags.unsaved = true;
|
||||||
}
|
}
|
||||||
chunk->updateHeights();
|
chunk->updateHeights();
|
||||||
|
|
||||||
if (!chunk->flags.loadedLights) {
|
if (!chunkFlags.loadedLights) {
|
||||||
Lighting::prebuildSkyLight(
|
Lighting::prebuildSkyLight(
|
||||||
chunk.get(), level->content->getIndices()
|
chunk.get(), level->content->getIndices()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
chunk->flags.loaded = true;
|
chunkFlags.loaded = true;
|
||||||
chunk->flags.ready = true;
|
chunkFlags.ready = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,11 +47,12 @@ void LevelController::update(float delta, bool input, bool pause) {
|
|||||||
player->postUpdate(delta, input, pause);
|
player->postUpdate(delta, input, pause);
|
||||||
|
|
||||||
// erease null pointers
|
// erease null pointers
|
||||||
level->objects.erase(
|
auto& objects = level->objects;
|
||||||
|
objects.erase(
|
||||||
std::remove_if(
|
std::remove_if(
|
||||||
level->objects.begin(), level->objects.end(),
|
objects.begin(), objects.end(),
|
||||||
[](auto obj) { return obj == nullptr; }),
|
[](auto obj) { return obj == nullptr; }),
|
||||||
level->objects.end()
|
objects.end()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user