From 17d6d965dce2cda2ede4ef78a9885a4bf37716c1 Mon Sep 17 00:00:00 2001 From: Phil Wise Date: Thu, 19 Dec 2013 21:21:46 +0000 Subject: [PATCH] Use C++ initialization list This is the recommended approach for object initialization. The change doesn't affect binary size (although in theory it could make it smaller). --- Marlin/vector_3.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/Marlin/vector_3.cpp b/Marlin/vector_3.cpp index 8c8a0e1dc7..4538251abf 100644 --- a/Marlin/vector_3.cpp +++ b/Marlin/vector_3.cpp @@ -22,19 +22,9 @@ #ifdef ENABLE_AUTO_BED_LEVELING #include "vector_3.h" -vector_3::vector_3() -{ - this->x = 0; - this->y = 0; - this->z = 0; -} +vector_3::vector_3() : x(0), y(0), z(0) { } -vector_3::vector_3(float x, float y, float z) -{ - this->x = x; - this->y = y; - this->z = z; -} +vector_3::vector_3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { } vector_3 vector_3::cross(vector_3 left, vector_3 right) { @@ -62,7 +52,7 @@ vector_3 vector_3::get_normal() float vector_3::get_length() { - float length = sqrt((x * x) + (y * y) + (z * z)); + float length = sqrt((x * x) + (y * y) + (z * z)); return length; }