Use cJSON_Minify()
and fix missed const
opportunities
This commit is contained in:
@@ -31,6 +31,13 @@
|
|||||||
#include "rawimagesource.h"
|
#include "rawimagesource.h"
|
||||||
#include "rt_math.h"
|
#include "rt_math.h"
|
||||||
|
|
||||||
|
namespace rtengine
|
||||||
|
{
|
||||||
|
|
||||||
|
extern const Settings* settings;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
using namespace rtexif;
|
using namespace rtexif;
|
||||||
|
|
||||||
@@ -408,17 +415,21 @@ std::map<std::string, std::string> getAliases(const Glib::ustring& profile_dir)
|
|||||||
|
|
||||||
std::unique_ptr<char[]> buffer(new char[length + 1]);
|
std::unique_ptr<char[]> buffer(new char[length + 1]);
|
||||||
std::fseek(file.get(), 0, SEEK_SET);
|
std::fseek(file.get(), 0, SEEK_SET);
|
||||||
std::fread(buffer.get(), 1, length, file.get());
|
const std::size_t read = std::fread(buffer.get(), 1, length, file.get());
|
||||||
buffer[length] = 0;
|
buffer[read] = 0;
|
||||||
|
|
||||||
std::unique_ptr<cJSON> root(cJSON_Parse(buffer.get()));
|
cJSON_Minify(buffer.get());
|
||||||
|
const std::unique_ptr<cJSON> root(cJSON_Parse(buffer.get()));
|
||||||
if (!root || !root->child) {
|
if (!root || !root->child) {
|
||||||
|
if (settings->verbose) {
|
||||||
|
std::cout << "Could not parse 'camera_model_aliases.json' file." << std::endl;
|
||||||
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::string> res;
|
std::map<std::string, std::string> res;
|
||||||
|
|
||||||
for (cJSON* camera = root->child; camera; camera = camera->next) {
|
for (const cJSON* camera = root->child; camera; camera = camera->next) {
|
||||||
if (cJSON_IsArray(camera)) {
|
if (cJSON_IsArray(camera)) {
|
||||||
const std::size_t array_size = cJSON_GetArraySize(camera);
|
const std::size_t array_size = cJSON_GetArraySize(camera);
|
||||||
for (std::size_t index = 0; index < array_size; ++index) {
|
for (std::size_t index = 0; index < array_size; ++index) {
|
||||||
|
Reference in New Issue
Block a user