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
Conversation
There was a problem hiding this 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)); |
There was a problem hiding this comment.
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.); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this auto
?
There was a problem hiding this comment.
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.
No description provided.