Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make const loop variables global and drop const. #680

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

PetroZarytskyi
Copy link
Collaborator

@PetroZarytskyi PetroZarytskyi commented Dec 11, 2023

Currently, local variables in loops are moved to function globals (the initialization is replaced with an assignment in the same place). This is done for the variable's value to not get overwritten on the next loop iteration. However, this is currently not done for const variables since we didn't account for the fact they can be re-initialized with different values on different loop iterations. Therefore, we have to do the same process for const local variables but drop constness (they need to be reassigned every loop iteration).
Fixes #667.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Merging #680 (d057047) into master (ec5ea41) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #680   +/-   ##
=======================================
  Coverage   94.37%   94.37%           
=======================================
  Files          48       48           
  Lines        7061     7062    +1     
=======================================
+ Hits         6664     6665    +1     
  Misses        397      397           
Files Coverage Δ
lib/Differentiator/ReverseModeVisitor.cpp 95.72% <100.00%> (+<0.01%) ⬆️
Files Coverage Δ
lib/Differentiator/ReverseModeVisitor.cpp 95.72% <100.00%> (+<0.01%) ⬆️

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

We didn't take into account const variables inside loops can be re-initialized on different loop iterations so we have to store them just like non-const variables. const should be dropped to allow us to replace initializations with assignments.
Fixes vgvassilev#667.
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Owner

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very well! Thank you!

@vgvassilev vgvassilev merged commit 6a42b46 into vgvassilev:master Dec 12, 2023
76 checks passed
@PetroZarytskyi PetroZarytskyi deleted the const-loop-vars branch December 29, 2023 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression in RooFit with Clad master
2 participants