Skip to content

Code Arrangement Changes #6 - #5457

Merged
timosachsenberg merged 7 commits into
OpenMS:developfrom
Arraxx:codearrange6
Jul 28, 2021
Merged

timosachsenberg merged 7 commits into
OpenMS:developfrom
Arraxx:codearrange6

Conversation

@Arraxx

@Arraxx Arraxx commented Jul 25, 2021

Copy link
Copy Markdown
Contributor

Description

Code changes for better readability.

Checklist:

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes. (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI:

If your PR is failing you can check out

Note:

  • Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

// names_ has the union of all Element*, deleting this is sufficient to avoid mem leaks
map<string, const Element*>::iterator it = names_.begin();
for (; it != names_.end(); ++it)
for (map<string, const Element*>::iterator it = names_.begin(); it != names_.end(); ++it)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could probably be rewritten with structure binding

{
const_iterator cit = elements_.begin();
for (; cit != elements_.end(); ++cit)
for (const_iterator cit = elements_.begin(); cit != elements_.end(); ++cit)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

coudl be rewritten with range for loop

bool found = false;
iterator it = elements_.begin();
for (; it != elements_.end(); ++it)
for (iterator it = elements_.begin(); it != elements_.end(); ++it)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

here as well

const_iterator cit = elements_.begin();
for (; cit != elements_.end(); ++cit)

for (const_iterator cit = elements_.begin(); cit != elements_.end(); ++cit)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

here too

*/

IMSIsotopeDistribution & IMSIsotopeDistribution::operator=(const IMSIsotopeDistribution & distribution)
IMSIsotopeDistribution & IMSIsotopeDistribution::operator=(const IMSIsotopeDistribution & distribution)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

did you check if it can be defaulted? (= default) I dind't but could be a candidate

map<unsigned int, double> bor_abundance = {{10u, 0.19899999999999998}, {11u, 0.8009999999999999}};
map<unsigned int, double> bor_mass = {{10u, 10.012937000000001}, {11u, 11.009304999999999}};
buildElement_("Boron", "B", 5u, bor_abundance, bor_mass);
buildElement_("Bor", "B", 5u, bor_abundance, bor_mass);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

probably need to integrate the other change you made here

@Arraxx

Arraxx commented Jul 27, 2021

Copy link
Copy Markdown
Contributor Author

Ready for review @timosachsenberg

// names_ has the union of all Element*, deleting this is sufficient to avoid mem leaks
map<string, const Element*>::iterator it = names_.begin();
for (; it != names_.end(); ++it)
for (auto &[string,Element] : names_)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

better not to use a class name as variable name
for (auto &[s, element] : names_)

But I just realized that this might lead to an unused variable warning.
Maybe better to just use
for (auto it = names_.begin(); it != names_.end(); ++it)

@timosachsenberg
timosachsenberg merged commit fe62fff into OpenMS:develop Jul 28, 2021
@timosachsenberg

Copy link
Copy Markdown
Contributor

Nice. Thanks!

timosachsenberg added a commit that referenced this pull request Jul 28, 2021
* Code Arrangement Changes #6 (#5457)

* Code Arrangement Changes #6

* Update IMSAlphabet.cpp

* Update ElementDB.cpp

* Update ElementDB.cpp

* Update ElementDB.cpp

* Update ElementDB.cpp

Co-authored-by: Arraxx <[email protected]>

* fix operator< test

Co-authored-by: Aman Kumar <[email protected]>
Co-authored-by: Arraxx <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>
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.

2 participants