Fix: Set Buffer data via rvalue instead of lvalue#1817
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📜 Recent review details🧰 Additional context used🧠 Learnings (1)📚 Learning: 2026-03-24T22:39:04.364ZApplied to files:
🔇 Additional comments (2)
📝 WalkthroughWalkthroughReplace in-place copies with move semantics for locally-constructed segmentation-mask buffers in ImgDetectionsT and SegmentationMask; ChangesMove semantics optimization for segmentation mask handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/pipeline/datatype/SegmentationMask.cpp`:
- Around line 46-47: The file uses std::move in this translation unit (e.g., in
the code around setData and other call sites like setData(std::move(...)) in
SegmentationMask.cpp) but does not include <utility>, relying on transitive
includes; add `#include` <utility> to SegmentationMask.cpp near the other includes
to make the dependency explicit, and if SegmentationMask.hpp itself uses
std::move or is included by other units, add `#include` <utility> to
SegmentationMask.hpp as well to avoid transitive-include fragility.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 793452da-d8eb-4114-b775-2adc9cf0eb75
📒 Files selected for processing (2)
src/pipeline/datatype/ImgDetectionsT.cppsrc/pipeline/datatype/SegmentationMask.cpp
📜 Review details
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-03-24T22:39:04.364Z
Learnt from: MaticTonin
Repo: luxonis/depthai-core PR: 1732
File: src/pipeline/Pipeline.cpp:705-705
Timestamp: 2026-03-24T22:39:04.364Z
Learning: Do not flag the `!= ""` part of the auto-calibration condition as redundant when it appears in `PipelineImpl::build()` (or closely related pipeline build logic). If the code uses `utility::getEnvAs<std::string>(..., default)` with a default such as `"ON_START"`, the explicit empty-string guard may still be intentional to treat an explicitly empty env var as “OFF/disabled” (or to avoid special-casing elsewhere). Only consider removing `!= ""` if the codebase has an explicit, enforceable guarantee that `DEPTHAI_AUTOCALIBRATION` can never be set to an empty string (e.g., via validated parsing/CI checks); otherwise, keep the guard.
Applied to files:
src/pipeline/datatype/SegmentationMask.cppsrc/pipeline/datatype/ImgDetectionsT.cpp
🔇 Additional comments (1)
src/pipeline/datatype/ImgDetectionsT.cpp (1)
7-7: LGTM!Also applies to: 31-33, 44-46, 92-94
Purpose
Segmentation mask data is stored in
std::shared_ptr<Memory> data. When setting the segmask via lvalue, it uses the following function:If the new
dis smaller than the current VectorMemory size, thendata->getSize()will return old memory size.Setting a segmentation mask should replace the underlying memory or perform copy-on-write, not mutate shared storage in place. So setting via rvalue is needed:
Specification
None / not applicable
Dependencies & Potential Impact
None / not applicable
Deployment Plan
None / not applicable
Testing & Validation
None / not applicable
AI Usage
Assisted-by: codex:5.4 xhigh
Submitted code was reviewed by a human: YES
The author is taking the responsibility for the contribution: YES
Summary by CodeRabbit