From bdbd6598ad3619cbf70bb9bf1443bfc1d314a374 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Jun 2024 20:45:00 +1000 Subject: [PATCH] Cleanup: various non-functional changes - Use brief `uint` type name. - Remove unnecessary "struct". - Remove duplicate variable declaration. - Pass arguments by const reference instead of value. - Use const argument. --- source/blender/animrig/intern/keyframing.cc | 2 +- source/blender/blenloader/intern/versioning_400.cc | 4 +--- source/blender/editors/include/UI_abstract_view.hh | 2 +- source/blender/editors/interface/views/abstract_view.cc | 2 +- source/blender/editors/space_sequencer/sequencer_select.cc | 2 +- source/blender/editors/space_sequencer/space_sequencer.cc | 2 +- source/blender/editors/transform/transform_input.cc | 1 - source/blender/imbuf/IMB_thumbs.hh | 2 +- source/blender/imbuf/intern/thumbs_font.cc | 2 +- source/blender/io/usd/intern/usd_capi_export.cc | 6 +++--- source/blender/nodes/shader/materialx/node_item.cc | 2 +- source/creator/creator.cc | 2 +- 12 files changed, 13 insertions(+), 16 deletions(-) diff --git a/source/blender/animrig/intern/keyframing.cc b/source/blender/animrig/intern/keyframing.cc index 88c55b048a8..3f28e56dba5 100644 --- a/source/blender/animrig/intern/keyframing.cc +++ b/source/blender/animrig/intern/keyframing.cc @@ -1141,7 +1141,7 @@ CombinedKeyingResult insert_key_rna(PointerRNA *rna_pointer, ListBase nla_cache = {nullptr, nullptr}; NlaKeyframingContext *nla_context = nullptr; - if (adt && adt->action == action) { + if (adt->action == action) { PointerRNA id_pointer = RNA_id_pointer_create(id); nla_context = BKE_animsys_get_nla_keyframing_context( &nla_cache, &id_pointer, adt, &anim_eval_context); diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 5b1a89aee52..ae204a12a90 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -3906,9 +3906,7 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 31)) { bool only_uses_eevee_legacy_or_workbench = true; LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { - if (!(STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE) || - STREQ(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH))) - { + if (!STR_ELEM(scene->r.engine, RE_engine_id_BLENDER_EEVEE, RE_engine_id_BLENDER_WORKBENCH)) { only_uses_eevee_legacy_or_workbench = false; } } diff --git a/source/blender/editors/include/UI_abstract_view.hh b/source/blender/editors/include/UI_abstract_view.hh index f2d0dae2b41..4d087819394 100644 --- a/source/blender/editors/include/UI_abstract_view.hh +++ b/source/blender/editors/include/UI_abstract_view.hh @@ -110,7 +110,7 @@ class AbstractView { std::optional get_bounds() const; std::string get_context_menu_title() const; - void set_context_menu_title(std::string title); + void set_context_menu_title(const std::string &title); protected: AbstractView() = default; diff --git a/source/blender/editors/interface/views/abstract_view.cc b/source/blender/editors/interface/views/abstract_view.cc index e229a231687..2bb8e0a7ee8 100644 --- a/source/blender/editors/interface/views/abstract_view.cc +++ b/source/blender/editors/interface/views/abstract_view.cc @@ -159,7 +159,7 @@ std::string AbstractView::get_context_menu_title() const return context_menu_title; } -void AbstractView::set_context_menu_title(std::string title) +void AbstractView::set_context_menu_title(const std::string &title) { context_menu_title = title; } diff --git a/source/blender/editors/space_sequencer/sequencer_select.cc b/source/blender/editors/space_sequencer/sequencer_select.cc index 605447890e3..fbf61455ac2 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.cc +++ b/source/blender/editors/space_sequencer/sequencer_select.cc @@ -848,7 +848,7 @@ bool ED_sequencer_handle_is_selected(const Sequence *seq, eSeqHandle handle) ((handle == SEQ_HANDLE_RIGHT) && (seq->flag & SEQ_RIGHTSEL)); } -static bool element_already_selected(const StripSelection selection) +static bool element_already_selected(const StripSelection &selection) { if (selection.seq1 == nullptr) { return false; diff --git a/source/blender/editors/space_sequencer/space_sequencer.cc b/source/blender/editors/space_sequencer/space_sequencer.cc index 608fafa374c..ef9abfb80bf 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.cc +++ b/source/blender/editors/space_sequencer/space_sequencer.cc @@ -683,7 +683,7 @@ static void sequencer_main_cursor(wmWindow *win, ScrArea *area, ARegion *region) const Scene *scene = win->scene; const Editing *ed = SEQ_editing_get(scene); - if (ed == NULL) { + if (ed == nullptr) { WM_cursor_set(win, wmcursor); return; } diff --git a/source/blender/editors/transform/transform_input.cc b/source/blender/editors/transform/transform_input.cc index 00bca595faa..ea465dfc672 100644 --- a/source/blender/editors/transform/transform_input.cc +++ b/source/blender/editors/transform/transform_input.cc @@ -331,7 +331,6 @@ static int transform_seq_slide_cursor_get(TransInfo *t) return WM_CURSOR_NSEW_SCROLL; } - const Scene *scene = t->scene; if (SEQ_time_right_handle_frame_get(scene, seq1) != SEQ_time_left_handle_frame_get(scene, seq2)) { diff --git a/source/blender/imbuf/IMB_thumbs.hh b/source/blender/imbuf/IMB_thumbs.hh index 527658e85e7..d176cf25097 100644 --- a/source/blender/imbuf/IMB_thumbs.hh +++ b/source/blender/imbuf/IMB_thumbs.hh @@ -91,7 +91,7 @@ ImBuf *IMB_thumb_load_blend(const char *blen_path, const char *blen_group, const ImBuf *IMB_thumb_load_font(const char *filename, unsigned int x, unsigned int y); bool IMB_thumb_load_font_get_hash(char *r_hash); -ImBuf *IMB_font_preview(const char *filename, unsigned int width, float color[4]); +ImBuf *IMB_font_preview(const char *filename, unsigned int width, const float color[4]); /* Threading */ diff --git a/source/blender/imbuf/intern/thumbs_font.cc b/source/blender/imbuf/intern/thumbs_font.cc index cbf56e3fcdb..5802b94cafc 100644 --- a/source/blender/imbuf/intern/thumbs_font.cc +++ b/source/blender/imbuf/intern/thumbs_font.cc @@ -46,7 +46,7 @@ bool IMB_thumb_load_font_get_hash(char *r_hash) return true; } -ImBuf *IMB_font_preview(const char *filename, unsigned int width, float color[4]) +ImBuf *IMB_font_preview(const char *filename, uint width, const float color[4]) { int font_id = (filename[0] != '<') ? BLF_load(filename) : 0; const char sample[] = "ABCDEFGH\nabcdefg123"; diff --git a/source/blender/io/usd/intern/usd_capi_export.cc b/source/blender/io/usd/intern/usd_capi_export.cc index 531c8d2b2e7..b7f62505c33 100644 --- a/source/blender/io/usd/intern/usd_capi_export.cc +++ b/source/blender/io/usd/intern/usd_capi_export.cc @@ -206,12 +206,12 @@ static void process_usdz_textures(const ExportJobData *data, const char *path) enum_value)); char texture_path[FILE_MAX]; - BLI_strncpy(texture_path, path, FILE_MAX); + STRNCPY(texture_path, path); BLI_path_append(texture_path, FILE_MAX, "textures"); BLI_path_slash_ensure(texture_path, sizeof(texture_path)); - struct direntry *entries; - unsigned int num_files = BLI_filelist_dir_contents(texture_path, &entries); + direntry *entries; + uint num_files = BLI_filelist_dir_contents(texture_path, &entries); for (int index = 0; index < num_files; index++) { /* We can skip checking extensions as this folder is only created diff --git a/source/blender/nodes/shader/materialx/node_item.cc b/source/blender/nodes/shader/materialx/node_item.cc index 6aab7039677..9d10ab34365 100644 --- a/source/blender/nodes/shader/materialx/node_item.cc +++ b/source/blender/nodes/shader/materialx/node_item.cc @@ -766,7 +766,7 @@ NodeItem NodeItem::create_node(const std::string &category, Type type) const NodeItem res = empty(); /* Surface-shader nodes and materials are added directly to the document, * otherwise to the node-graph. */ - if (type == Type::SurfaceShader || type == Type::Material) { + if (ELEM(type, Type::SurfaceShader, Type::Material)) { res.node = graph_->getDocument()->addNode(category, MaterialX::EMPTY_STRING, type_str); } else { diff --git a/source/creator/creator.cc b/source/creator/creator.cc index ff2a9c5031e..d0da56bf461 100644 --- a/source/creator/creator.cc +++ b/source/creator/creator.cc @@ -331,7 +331,7 @@ int main(int argc, #endif /* WIN32 */ #if defined(WITH_OPENGL_BACKEND) && defined(BLI_SUBPROCESS_SUPPORT) - if (strcmp(argv[0], "--compilation-subprocess") == 0) { + if (STREQ(argv[0], "--compilation-subprocess")) { BLI_assert(argc == 2); GPU_compilation_subprocess_run(argv[1]); return 0;