Const correctness improvements:

removed some unnecessary const_casts that remove const.
This commit is contained in:
bubnikv 2020-01-03 16:32:56 +01:00
parent 30f7a2b8e5
commit 9406b50447
13 changed files with 41 additions and 40 deletions

View file

@ -205,7 +205,7 @@ size_t Index::load(const boost::filesystem::path &path)
#endif
++ idx_line;
// Skip the initial white spaces.
char *key = left_trim(const_cast<char*>(line.data()));
char *key = left_trim(line.data());
if (*key == '#')
// Skip a comment line.
continue;

View file

@ -338,7 +338,7 @@ void Camera::debug_render() const
float fov = (float)get_fov();
float gui_scale = (float)get_gui_scale();
ImGui::InputText("Type", const_cast<char*>(type.data()), type.length(), ImGuiInputTextFlags_ReadOnly);
ImGui::InputText("Type", type.data(), type.length(), ImGuiInputTextFlags_ReadOnly);
ImGui::Separator();
ImGui::InputFloat3("Position", position.data(), "%.6f", ImGuiInputTextFlags_ReadOnly);
ImGui::InputFloat3("Target", target.data(), "%.6f", ImGuiInputTextFlags_ReadOnly);

View file

@ -142,7 +142,7 @@ bool GLShader::load_from_file(const char* fragment_shader_filename, const char*
int file_length = (int)vs.tellg();
vs.seekg(0, vs.beg);
std::string vertex_shader(file_length, '\0');
vs.read(const_cast<char*>(vertex_shader.data()), file_length);
vs.read(vertex_shader.data(), file_length);
if (!vs.good())
return false;
@ -156,7 +156,7 @@ bool GLShader::load_from_file(const char* fragment_shader_filename, const char*
file_length = (int)fs.tellg();
fs.seekg(0, fs.beg);
std::string fragment_shader(file_length, '\0');
fs.read(const_cast<char*>(fragment_shader.data()), file_length);
fs.read(fragment_shader.data(), file_length);
if (!fs.good())
return false;

View file

@ -560,9 +560,11 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
while (filament_configs.size() < num_extruders)
filament_configs.emplace_back(&this->filaments.first_visible().config);
for (const DynamicPrintConfig *cfg : filament_configs) {
compatible_printers_condition.emplace_back(Preset::compatible_printers_condition(*const_cast<DynamicPrintConfig*>(cfg)));
compatible_prints_condition .emplace_back(Preset::compatible_prints_condition(*const_cast<DynamicPrintConfig*>(cfg)));
inherits .emplace_back(Preset::inherits(*const_cast<DynamicPrintConfig*>(cfg)));
// The compatible_prints/printers_condition() returns a reference to configuration key, which may not yet exist.
DynamicPrintConfig &cfg_rw = *const_cast<DynamicPrintConfig*>(cfg);
compatible_printers_condition.emplace_back(Preset::compatible_printers_condition(cfg_rw));
compatible_prints_condition .emplace_back(Preset::compatible_prints_condition(cfg_rw));
inherits .emplace_back(Preset::inherits(cfg_rw));
}
// Option values to set a ConfigOptionVector from.
std::vector<const ConfigOption*> filament_opts(num_extruders, nullptr);

View file

@ -325,7 +325,7 @@ void RemovableDriveManager::inspect_file(const std::string &path, const std::str
{
if(pw->pw_name == username)
{
std::string name = basename(const_cast<char*>(path.c_str()));
std::string name = basename(path.data());
m_current_drives.push_back(DriveData(name,path));
}
}