Skip to content

Commit

Permalink
Capture return values by reference to avoid copies.
Browse files Browse the repository at this point in the history
Refs #12584
  • Loading branch information
martyngigg committed Jun 25, 2015
1 parent 17453fe commit 1f9d645
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Code/Mantid/Framework/Geometry/src/Math/PolygonEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Kernel::V2D PolygonEdge::point(const double fraction) const {
*/
PointClassification classify(const V2D &pt, const PolygonEdge &edge) {
V2D p2 = pt;
V2D a = edge.end() - edge.start();
const V2D &a = edge.direction();
V2D b = p2 - edge.start();
double sa = a.X() * b.Y() - b.X() * a.Y();
if (sa > 0.0) {
Expand Down Expand Up @@ -80,8 +80,7 @@ PolygonEdge::Orientation orientation(const PolygonEdge &focusEdge,
const PolygonEdge &refEdge, double &t) {
V2D normalToRef((refEdge.end().Y() - refEdge.start().Y()),
(refEdge.start().X() - refEdge.end().X()));
V2D focusDir = focusEdge.end() - focusEdge.start();
double denom = normalToRef.scalar_prod(focusDir);
double denom = normalToRef.scalar_prod(focusEdge.direction());
if (Kernel::equals(denom, 0.0)) {
PointClassification edgeClass = classify(focusEdge.start(), refEdge);
if (edgeClass == OnLeft || edgeClass == OnRight) {
Expand Down Expand Up @@ -113,13 +112,13 @@ PolygonEdge::Orientation crossingPoint(const PolygonEdge &edgeOne,
if (classe == PolygonEdge::Collinear || classe == PolygonEdge::Parallel) {
return classe;
}
double lene = (edgeOne.end() - edgeOne.start()).norm();
double lene = edgeOne.direction().norm();
if ((s < -EPSILON * lene) || (s > 1.0 + EPSILON * lene)) {
return PolygonEdge::SkewNoCross;
}
double t(0.0);
orientation(edgeTwo, edgeOne, t);
double lenf = (edgeTwo.start() - edgeTwo.end()).norm();
double lenf = edgeTwo.direction().norm();
if (ltEquals(-EPSILON * lenf, t) && ltEquals(t, 1.0 + EPSILON * lenf)) {
if (ltEquals(t, EPSILON * lenf)) {
crossPoint = edgeTwo.start();
Expand Down Expand Up @@ -148,8 +147,8 @@ PolygonEdge::Orientation crossingPoint(const PolygonEdge &edgeOne,
bool edgeAimsAt(const PolygonEdge &a, const PolygonEdge &b,
PointClassification aclass,
PolygonEdge::Orientation crossType) {
V2D va = a.direction();
V2D vb = b.direction();
const auto & va = a.direction();
const auto & vb = b.direction();
if (crossType != PolygonEdge::Collinear) {
double ca = va.X() * vb.Y();
double cb = vb.X() * va.Y();
Expand Down

0 comments on commit 1f9d645

Please sign in to comment.