Clean up setGeometry (16_x)#5714
Conversation
Reorganize setGeometry to perform all checks first before applying the values. This lets us accurately detect changes before starting a transition.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
ChangessetGeometry Refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant Segment
participant PixelBuffer
participant LightCapabilities
Caller->>Segment: setGeometry(...)
Segment->>Segment: sanitize inputs and compute boundsUnchanged
alt no geometry change
Segment-->>Caller: return
else geometry changed
Segment->>Segment: mark reset, stop transition, set stateChanged
Segment->>Segment: assign geometry fields
alt length() == 0
Segment->>PixelBuffer: free pixels and deallocate data
else length() changed
Segment->>PixelBuffer: reallocate pixels if needed
Segment->>LightCapabilities: refreshLightCapabilities()
end
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
wled00/FX_fcn.cpp (1)
520-523: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRedundant duplicate assignment of
stateChanged.
stateChanged = true;is set identically on Line 520 and Line 523; neithermarkForReset()norstopTransition()clears it, so the second assignment is dead. Likely a port/merge artifact — remove one.♻️ Proposed cleanup
- stateChanged = true; // send UDP/WS broadcast markForReset(); stopTransition(); // we can't use transition if segment dimensions changed stateChanged = true; // send UDP/WS broadcastAs per path instructions: "CHECK for singleton data (defined but never used) and for dead/disabled code, and suggest to remove them" and "FLAG changes that appear unrelated".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@wled00/FX_fcn.cpp` around lines 520 - 523, The `stateChanged` flag is being assigned the same value twice in the segment-dimension reset flow, making the later assignment dead. In the `FX_fcn.cpp` logic around `markForReset()` and `stopTransition()`, remove the redundant `stateChanged = true` so the broadcast flag is set only once and keep the existing reset/transition calls unchanged.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@wled00/FX_fcn.cpp`:
- Around line 520-523: The `stateChanged` flag is being assigned the same value
twice in the segment-dimension reset flow, making the later assignment dead. In
the `FX_fcn.cpp` logic around `markForReset()` and `stopTransition()`, remove
the redundant `stateChanged = true` so the broadcast flag is set only once and
keep the existing reset/transition calls unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2ca0626b-2bf1-4a75-9f5a-ab3a838c9abb
📒 Files selected for processing (1)
wled00/FX_fcn.cpp
Reorganize setGeometry to perform all checks first before applying the values. This lets us accurately detect changes before starting a transition.
16.x port of #5474
Summary by CodeRabbit