Browse Source

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).
Phil Wise 10 years ago
parent
commit
17d6d965dc
1 changed files with 3 additions and 13 deletions
  1. 3
    13
      Marlin/vector_3.cpp

+ 3
- 13
Marlin/vector_3.cpp View File

@@ -22,19 +22,9 @@
22 22
 #ifdef ENABLE_AUTO_BED_LEVELING
23 23
 #include "vector_3.h"
24 24
 
25
-vector_3::vector_3()
26
-{
27
-  this->x = 0;
28
-  this->y = 0;
29
-  this->z = 0;
30
-}
25
+vector_3::vector_3() : x(0), y(0), z(0) { }
31 26
 
32
-vector_3::vector_3(float x, float y, float z)
33
-{
34
-	this->x = x;
35
-	this->y = y;
36
-	this->z = z;
37
-}
27
+vector_3::vector_3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { }
38 28
 
39 29
 vector_3 vector_3::cross(vector_3 left, vector_3 right)
40 30
 {
@@ -62,7 +52,7 @@ vector_3 vector_3::get_normal()
62 52
 
63 53
 float vector_3::get_length() 
64 54
 {
65
-        float length = sqrt((x * x) + (y * y) + (z * z));
55
+	float length = sqrt((x * x) + (y * y) + (z * z));
66 56
 	return length;
67 57
 }
68 58
  

Loading…
Cancel
Save