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

DM-10227: Replace raw arrays with std::vector #217

Merged
merged 2 commits into from Apr 5, 2022
Merged

Conversation

mwittgen
Copy link
Contributor

@mwittgen mwittgen commented Apr 4, 2022

No description provided.

Copy link
Collaborator

@parejkoj parejkoj left a comment

Choose a reason for hiding this comment

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

I believe chi2_array and chi2_cleanup could both be moved to an anonymous namespace in StarMatch.cc.

src/StarMatch.cc Outdated
@@ -245,7 +244,7 @@ double computeDist2(const StarMatchList &starMatchList, const AstrometryTransfor

double computeChi2(const StarMatchList &starMatchList, const AstrometryTransform &transform) {
unsigned s = starMatchList.size();
std::unique_ptr<double[]> chi2s(chi2_array(starMatchList, transform));
std::vector<double> chi2s(chi2_array(starMatchList, transform));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Worth making this auto?

src/StarMatch.cc Outdated
const AstrometryTransform &transform) {
unsigned s = starMatchList.size();
auto res = std::unique_ptr<double[]>(new double[s]);
std::vector<double> res(s,0.);
Copy link
Collaborator

Choose a reason for hiding this comment

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

While we're at it, lets replace res->result and s->size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.
std::vector<double> result also does not need to be default intialized

@@ -116,12 +115,12 @@ void StarMatchList::refineTransform(double nSigmas) {
if (npair == 0) break; // should never happen

// compute some chi2 statistics
std::unique_ptr<double[]> chi2_array(new double[npair]);
std::vector<double> chi2_array(npair);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make this auto?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Also use ranged based loop.

@mwittgen mwittgen merged commit f3933af into main Apr 5, 2022
@mwittgen mwittgen deleted the tickets/DM-10227 branch April 5, 2022 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants