浏览代码

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 11 年前
父节点
当前提交
17d6d965dc
共有 1 个文件被更改,包括 3 次插入13 次删除
  1. 3
    13
      Marlin/vector_3.cpp

+ 3
- 13
Marlin/vector_3.cpp 查看文件

22
 #ifdef ENABLE_AUTO_BED_LEVELING
22
 #ifdef ENABLE_AUTO_BED_LEVELING
23
 #include "vector_3.h"
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
 vector_3 vector_3::cross(vector_3 left, vector_3 right)
29
 vector_3 vector_3::cross(vector_3 left, vector_3 right)
40
 {
30
 {
62
 
52
 
63
 float vector_3::get_length() 
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
 	return length;
56
 	return length;
67
 }
57
 }
68
  
58
  

正在加载...
取消
保存