Skip to content

[Type] Vec: Short-circuit toVecN for same-type conversions#6022

Open
fredroy wants to merge 1 commit intosofa-framework:masterfrom
fredroy:vec_avoid_convert_same_type
Open

[Type] Vec: Short-circuit toVecN for same-type conversions#6022
fredroy wants to merge 1 commit intosofa-framework:masterfrom
fredroy:vec_avoid_convert_same_type

Conversation

@fredroy
Copy link
Contributor

@fredroy fredroy commented Mar 17, 2026

Skip conversion logic when both Vec types are the same. The compiler likely optimizes this already, but the explicit check makes the intent clearer and avoids relying on the optimizer to see through std::copy/std::fill_n.

Measured with alxbilger/SofaBenchmark#46
No change with -O3 but it should make lesser optimization/debug run faster

[with-all-tests]


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@fredroy fredroy added pr: enhancement About a possible enhancement pr: status to review To notify reviewers to review this pull-request labels Mar 17, 2026
@th-skam th-skam added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: enhancement About a possible enhancement pr: status ready Approved a pull-request, ready to be squashed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants