Revert "fix: optimization: Various PVS-Studio warnings"
This commit is contained in:
@@ -73,12 +73,11 @@ std::shared_ptr<Task> WorldConverter::startTask(
|
||||
[=](){return std::make_shared<ConverterWorker>(converter);},
|
||||
[=](int&) {}
|
||||
);
|
||||
auto& converterTasks = converter->tasks;
|
||||
while (!converterTasks.empty()) {
|
||||
const convert_task& task = converterTasks.front();
|
||||
while (!converter->tasks.empty()) {
|
||||
const convert_task& task = converter->tasks.front();
|
||||
auto ptr = std::make_shared<convert_task>(task);
|
||||
pool->enqueueJob(ptr);
|
||||
converterTasks.pop();
|
||||
converter->tasks.pop();
|
||||
}
|
||||
pool->setOnComplete([=]() {
|
||||
converter->write();
|
||||
|
||||
@@ -47,7 +47,8 @@ WorldFiles::WorldFiles(const fs::path& directory, const DebugSettings& settings)
|
||||
regions.doWriteLights = doWriteLights;
|
||||
}
|
||||
|
||||
WorldFiles::~WorldFiles() = default;
|
||||
WorldFiles::~WorldFiles() {
|
||||
}
|
||||
|
||||
void WorldFiles::createDirectories() {
|
||||
fs::create_directories(directory / fs::path("data"));
|
||||
|
||||
@@ -56,7 +56,8 @@ WorldRegion::WorldRegion()
|
||||
sizes(std::make_unique<uint32_t[]>(REGION_CHUNKS_COUNT))
|
||||
{}
|
||||
|
||||
WorldRegion::~WorldRegion() = default;
|
||||
WorldRegion::~WorldRegion() {
|
||||
}
|
||||
|
||||
void WorldRegion::setUnsaved(bool unsaved) {
|
||||
this->unsaved = unsaved;
|
||||
@@ -97,7 +98,8 @@ WorldRegions::WorldRegions(const fs::path& directory) : directory(directory) {
|
||||
layers[REGION_LAYER_ENTITIES].folder = directory/fs::path("entities");
|
||||
}
|
||||
|
||||
WorldRegions::~WorldRegions() = default;
|
||||
WorldRegions::~WorldRegions() {
|
||||
}
|
||||
|
||||
WorldRegion* WorldRegions::getRegion(int x, int z, int layer) {
|
||||
RegionsLayer& regions = layers[layer];
|
||||
@@ -196,7 +198,7 @@ ubyte* WorldRegions::getData(int x, int z, int layer, uint32_t& size) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
regfile_ptr WorldRegions::useRegFile(const glm::ivec3& coord) {
|
||||
regfile_ptr WorldRegions::useRegFile(glm::ivec3 coord) {
|
||||
auto* file = openRegFiles[coord].get();
|
||||
file->inUse = true;
|
||||
return regfile_ptr(file, ®FilesCv);
|
||||
@@ -208,7 +210,7 @@ void WorldRegions::closeRegFile(glm::ivec3 coord) {
|
||||
}
|
||||
|
||||
// Marks regfile as used and unmarks when shared_ptr dies
|
||||
regfile_ptr WorldRegions::getRegFile(const glm::ivec3& coord, bool create) {
|
||||
regfile_ptr WorldRegions::getRegFile(glm::ivec3 coord, bool create) {
|
||||
{
|
||||
std::lock_guard lock(regFilesMutex);
|
||||
const auto found = openRegFiles.find(coord);
|
||||
@@ -225,7 +227,7 @@ regfile_ptr WorldRegions::getRegFile(const glm::ivec3& coord, bool create) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
regfile_ptr WorldRegions::createRegFile(const glm::ivec3& coord) {
|
||||
regfile_ptr WorldRegions::createRegFile(glm::ivec3 coord) {
|
||||
fs::path file = layers[coord[2]].folder/getRegionFilename(coord[0], coord[1]);
|
||||
if (!fs::exists(file)) {
|
||||
return nullptr;
|
||||
@@ -352,7 +354,7 @@ static std::unique_ptr<ubyte[]> write_inventories(Chunk* chunk, uint& datasize)
|
||||
}
|
||||
|
||||
/// @brief Store chunk data (voxels and lights) in region (existing or new)
|
||||
void WorldRegions::put(Chunk* chunk, const std::vector<ubyte>& entitiesData){
|
||||
void WorldRegions::put(Chunk* chunk, std::vector<ubyte> entitiesData){
|
||||
assert(chunk != nullptr);
|
||||
if (!chunk->flags.lighted) {
|
||||
return;
|
||||
|
||||
@@ -149,10 +149,10 @@ class WorldRegions {
|
||||
|
||||
ubyte* getData(int x, int z, int layer, uint32_t& size);
|
||||
|
||||
regfile_ptr getRegFile(const glm::ivec3& coord, bool create=true);
|
||||
regfile_ptr getRegFile(glm::ivec3 coord, bool create=true);
|
||||
void closeRegFile(glm::ivec3 coord);
|
||||
regfile_ptr useRegFile(const glm::ivec3& coord);
|
||||
regfile_ptr createRegFile(const glm::ivec3& coord);
|
||||
regfile_ptr useRegFile(glm::ivec3 coord);
|
||||
regfile_ptr createRegFile(glm::ivec3 coord);
|
||||
|
||||
fs::path getRegionFilename(int x, int y) const;
|
||||
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
~WorldRegions();
|
||||
|
||||
/// @brief Put all chunk data to regions
|
||||
void put(Chunk* chunk, const std::vector<ubyte>& entitiesData);
|
||||
void put(Chunk* chunk, std::vector<ubyte> entitiesData);
|
||||
|
||||
/// @brief Store data in specified region
|
||||
/// @param x chunk.x
|
||||
|
||||
@@ -214,7 +214,7 @@ std::vector<std::string> ResPaths::listdirRaw(const std::string& folderName) con
|
||||
continue;
|
||||
for (const auto& entry : fs::directory_iterator(folder)) {
|
||||
auto name = entry.path().filename().u8string();
|
||||
entries.emplace_back(root.name+":"+folderName+"/"+name);
|
||||
entries.push_back(root.name+":"+folderName+"/"+name);
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -223,7 +223,7 @@ std::vector<std::string> ResPaths::listdirRaw(const std::string& folderName) con
|
||||
return entries;
|
||||
for (const auto& entry : fs::directory_iterator(folder)) {
|
||||
auto name = entry.path().filename().u8string();
|
||||
entries.emplace_back("core:"+folderName+"/"+name);
|
||||
entries.push_back("core:"+folderName+"/"+name);
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ std::string files::read_string(const fs::path& filename) {
|
||||
return std::string((const char*)bytes.get(), size);
|
||||
}
|
||||
|
||||
bool files::write_string(const fs::path& filename, const std::string& content) {
|
||||
bool files::write_string(const fs::path& filename, const std::string content) {
|
||||
std::ofstream file(filename);
|
||||
if (!file) {
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ namespace files {
|
||||
uint append_bytes(const fs::path& file, const ubyte* data, size_t size);
|
||||
|
||||
/// @brief Write string to the file
|
||||
bool write_string(const fs::path& filename, const std::string& content);
|
||||
bool write_string(const fs::path& filename, const std::string content);
|
||||
|
||||
/// @brief Write dynamic data to the JSON file
|
||||
/// @param nice if true, human readable format will be used, otherwise minimal
|
||||
|
||||
Reference in New Issue
Block a user