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 setTwist/twist take/return a const reference. #4719

Merged
merged 3 commits into from
Aug 31, 2023

Conversation

quantumsteve
Copy link
Contributor

Please review the developer documentation
on the wiki of this project that contains help and requirements.

Proposed changes

Describe what this PR changes and why. If it closes an issue, link to it here
with a supported keyword.

Cleaning up a getter and setter that generate unnecessary copies. Functions were found during work on #4684.

What type(s) of changes does this code introduce?

Delete the items that do not apply

  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)

Does this introduce a breaking change?

  • No

What systems has this change been tested on?

Checklist

Update the following with a yes where the items apply. If you're unsure about any of them, don't hesitate to ask. This is
simply a reminder of what we are going to look for before merging your code.

  • Yes This PR is up to date with current the current state of 'develop'
  • Yes Code added or changed in the PR has been clang-formatted

@@ -102,7 +102,8 @@ std::unique_ptr<TrialWaveFunction> WaveFunctionFactory::buildTWF(xmlNodePtr cur,
if (!foundtwist)
{
//default twist is [0 0 0]
std::vector<ParticleSet::RealType> tsts(3, 0);
tsts.resize(3);
Copy link
Contributor

Choose a reason for hiding this comment

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

tsts is size 3 in the declaration (and set to 0) in the declaration. Is there a need to set it again here?

Copy link
Contributor

Choose a reason for hiding this comment

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

The original code where the declaration of 'tsts' occurs right before the use seems clear to me, but maybe I'm missing something?

Copy link
Contributor

Choose a reason for hiding this comment

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

Except for the name. In isolation, I would read 'tsts' as 'tests'. Maybe it could be expanded to 'twists'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the name and added a rvalue function overload to avoid the extra copy.

@markdewing
Copy link
Contributor

Test this please

@prckent prckent enabled auto-merge August 31, 2023 17:57
@prckent prckent merged commit 155b0f1 into QMCPACK:develop Aug 31, 2023
22 of 23 checks passed
@quantumsteve quantumsteve deleted the faster_setTwist branch August 31, 2023 18:56
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.

3 participants