Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 71e8a3a

Browse files
committed
Compact the operator/
1 parent 3744e8c commit 71e8a3a

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

System/Vector.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -442,23 +442,15 @@ namespace RTE {
442442
/// </summary>
443443
/// <param name="rhs">A float reference as the right hand side operand.</param>
444444
/// <returns>The resulting Vector.</returns>
445-
Vector operator/(const float &rhs) const {
446-
Vector returnVector(0, 0);
447-
if (rhs != 0) { returnVector.SetXY(m_X / rhs, m_Y / rhs); }
448-
return returnVector;
449-
}
445+
Vector operator/(const float &rhs) const { return (rhs != 0) ? Vector(m_X / rhs, m_Y / rhs) : Vector(0, 0); }
450446

451447
/// <summary>
452448
/// Division operator overload for Vectors.
453449
/// </summary>
454450
/// <param name="lhs">A Vector reference as the left hand side operand.</param>
455451
/// <param name="rhs">A Vector reference as the right hand side operand.</param>
456452
/// <returns>The resulting Vector.</returns>
457-
friend Vector operator/(const Vector &lhs, const Vector &rhs) {
458-
Vector returnVector(0, 0);
459-
if (rhs.m_X != 0 && rhs.m_Y != 0) { returnVector.SetXY(lhs.m_X / rhs.m_X, lhs.m_Y / rhs.m_Y); }
460-
return returnVector;
461-
}
453+
friend Vector operator/(const Vector &lhs, const Vector &rhs) { return (rhs.m_X != 0 && rhs.m_Y != 0) ? Vector(lhs.m_X / rhs.m_X, lhs.m_Y / rhs.m_Y) : Vector(0, 0); }
462454

463455
/// <summary>
464456
/// Self-addition operator overload for Vectors.

0 commit comments

Comments
 (0)