Cleanup: use const pointers where possible

This commit is contained in:
Campbell Barton 2024-05-28 13:35:25 +10:00
parent 91c7809640
commit c110d26c61
6 changed files with 20 additions and 20 deletions

View File

@ -355,7 +355,7 @@ static bool reuse_bmain_move_id(ReuseOldBMainData *reuse_data,
static Library *reuse_bmain_data_dependencies_new_library_get(ReuseOldBMainData *reuse_data,
Library *old_lib)
{
id::IDRemapper &remapper = reuse_bmain_data_remapper_ensure(reuse_data);
const id::IDRemapper &remapper = reuse_bmain_data_remapper_ensure(reuse_data);
Library *new_lib = old_lib;
IDRemapperApplyResult result = remapper.apply(reinterpret_cast<ID **>(&new_lib),
ID_REMAP_APPLY_DEFAULT);

View File

@ -982,7 +982,7 @@ static bool read_file_dna(FileData *fd, const char **r_error_message)
}
/* We can't use read_global because this needs 'DNA1' to be decoded,
* however the first 4 chars are _always_ the subversion. */
FileGlobal *fg = reinterpret_cast<FileGlobal *>(&bhead[1]);
const FileGlobal *fg = reinterpret_cast<const FileGlobal *>(&bhead[1]);
BLI_STATIC_ASSERT(offsetof(FileGlobal, subvstr) == 0, "Must be first: subvstr")
char num[5];
memcpy(num, fg->subvstr, 4);

View File

@ -619,8 +619,8 @@ static void mywrite_id_begin(WriteData *wd, ID *id)
/* If current next memchunk does not match the ID we are about to write, or is not the _first_
* one for said ID, try to find the correct memchunk in the mapping using ID's session_uid. */
MemFileChunk *curr_memchunk = wd->mem.reference_current_chunk;
MemFileChunk *prev_memchunk = curr_memchunk != nullptr ?
const MemFileChunk *curr_memchunk = wd->mem.reference_current_chunk;
const MemFileChunk *prev_memchunk = curr_memchunk != nullptr ?
static_cast<MemFileChunk *>(curr_memchunk->prev) :
nullptr;
if (curr_memchunk == nullptr || curr_memchunk->id_session_uid != id->session_uid ||

View File

@ -65,7 +65,7 @@ static eDRWColorManagementType drw_color_management_type_for_v3d(const Scene &sc
static eDRWColorManagementType drw_color_management_type_for_space_image(const SpaceImage &sima)
{
Image *image = sima.image;
const Image *image = sima.image;
/* Use inverse logic as there isn't a setting for `Color & Alpha`. */
const eSpaceImage_Flag display_channels_mode = static_cast<eSpaceImage_Flag>(sima.flag);
@ -83,7 +83,7 @@ static eDRWColorManagementType drw_color_management_type_for_space_node(Main &bm
const SpaceNode &snode)
{
if ((snode.flag & SNODE_BACKDRAW) && ED_node_is_compositor(&snode)) {
Image *image = BKE_image_ensure_viewer(&bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
const Image *image = BKE_image_ensure_viewer(&bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
if ((image->flag & IMA_VIEW_AS_RENDER) == 0) {
return eDRWColorManagementType::ViewTransform;
}

View File

@ -489,7 +489,7 @@ static void PREFERENCES_OT_extension_repo_add(wmOperatorType *ot)
{ /* Name. */
const char *prop_id = "name";
PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
PropertyRNA *prop = RNA_def_string(ot->srna,
prop_id,
nullptr,
@ -501,7 +501,7 @@ static void PREFERENCES_OT_extension_repo_add(wmOperatorType *ot)
{ /* Remote Path. */
const char *prop_id = "remote_url";
PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
PropertyRNA *prop = RNA_def_string(ot->srna,
prop_id,
nullptr,
@ -513,7 +513,7 @@ static void PREFERENCES_OT_extension_repo_add(wmOperatorType *ot)
{ /* Use Access Token. */
const char *prop_id = "use_access_token";
PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
PropertyRNA *prop = RNA_def_boolean(ot->srna,
prop_id,
false,
@ -524,7 +524,7 @@ static void PREFERENCES_OT_extension_repo_add(wmOperatorType *ot)
{ /* Access Token (dynamic length). */
const char *prop_id = "access_token";
PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
PropertyRNA *prop = RNA_def_string(ot->srna,
prop_id,
nullptr,
@ -537,7 +537,7 @@ static void PREFERENCES_OT_extension_repo_add(wmOperatorType *ot)
{ /* Check for Updated on Startup. */
const char *prop_id = "use_sync_on_startup";
PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
PropertyRNA *prop = RNA_def_boolean(ot->srna,
prop_id,
false,
@ -548,7 +548,7 @@ static void PREFERENCES_OT_extension_repo_add(wmOperatorType *ot)
{ /* Use Custom Directory. */
const char *prop_id = "use_custom_directory";
PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
PropertyRNA *prop = RNA_def_boolean(ot->srna,
prop_id,
false,
@ -559,7 +559,7 @@ static void PREFERENCES_OT_extension_repo_add(wmOperatorType *ot)
{ /* Custom Directory. */
const char *prop_id = "custom_directory";
PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
PropertyRNA *prop = RNA_def_string_dir_path(ot->srna,
prop_id,
nullptr,
@ -620,7 +620,7 @@ static int preferences_extension_repo_remove_invoke(bContext *C,
const int index = RNA_int_get(op->ptr, "index");
bUserExtensionRepoRemoveType repo_type = bUserExtensionRepoRemoveType(
RNA_enum_get(op->ptr, "type"));
bUserExtensionRepo *repo = static_cast<bUserExtensionRepo *>(
const bUserExtensionRepo *repo = static_cast<bUserExtensionRepo *>(
BLI_findlink(&U.extension_repos, index));
if (!repo) {

View File

@ -405,8 +405,8 @@ void render_result_clone_passes(Render *re, RenderResult *rr, const char *viewna
continue;
}
/* Compare fullname to make sure that the view also is equal. */
RenderPass *rp = static_cast<RenderPass *>(
/* Compare `fullname` to make sure that the view also is equal. */
const RenderPass *rp = static_cast<const RenderPass *>(
BLI_findstring(&rl->passes, main_rp->fullname, offsetof(RenderPass, fullname)));
if (!rp) {
render_layer_add_pass(
@ -652,8 +652,8 @@ static void *ml_addview_cb(void *base, const char *str)
static int order_render_passes(const void *a, const void *b)
{
/* 1 if `a` is after `b`. */
RenderPass *rpa = (RenderPass *)a;
RenderPass *rpb = (RenderPass *)b;
const RenderPass *rpa = (const RenderPass *)a;
const RenderPass *rpb = (const RenderPass *)b;
uint passtype_a = passtype_from_name(rpa->name);
uint passtype_b = passtype_from_name(rpb->name);