Cleanup: Reduce nesteds in node.cc #105509
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#105509
Loading…
Reference in New Issue
No description provided.
Delete Branch "mod_moder/blender:cleanup_reduce_nesteds"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Decompose most of the nesting in the code to make the code
more consistent along the line of program execution.
Mainly achieved through:
Thanks for the PR. To be honest though, it's quite hard to justify spend time reviewing this sort of cleanup. Compared to the amount of time review will take, the benefit is quite low. And the patch is large enough that it becomes a bit overwhelming about half-way through.
@ -1409,0 +1407,4 @@
return true;
}
if (!node->is_group()) {
Better to keep all of the checks that are only relevant to a group node in one block:
@ -2096,1 +2106,3 @@
ntree, reversed ? link->fromnode : link->tonode, callback, userdata, reversed);
/* TODO (mod_moder): This case less likely than the case below. Very less likely. Can swap.
* Need a benchmark.*/
if (ELEM(nullptr, link->tonode, link->fromnode)) {
Since recently, we can assume that both
tonode
andfromnode
will be non-null. This check is left over from the time when the currently dragged links were also stored in the node tree.@ -2244,2 +2280,3 @@
const char *disabled_hint;
if (ntype->type == type && (!ntype->poll || ntype->poll(ntype, ntree, &disabled_hint))) {
const bool can_by_created = ntype->poll(ntype, ntree, &disabled_hint);
I think the code was easier to read with
ntype->poll && !ntype->poll(...)
on the same line.I would like to complete my list of things that can be cleared in this file though (I can send it to you for approval if you want).
Reducing nesting is very useful for simplifying code. Already now it allows you to remove old unused things. Also, there is one TODO (maybe not noticed by you) that could potentially make a strong optimization (albeit not a very heavily loaded place in the code).
So this seems to have some potential for performance improvements as well.
In addition, it is also a fix for potential bugs.
@ -3748,0 +3758,4 @@
if (!stype.use_link_limits_of_type) {
return sock->limit;
}
if (sock->in_out == SOCK_IN) {
Personally I find this easier to read than what you've done here. It's a simple check and splitting it over multiple lines makes it seem more complex than it is.
return sock->in_out == SOCK_IN ? stype.input_link_limit : stype.output_link_limit;