Browse Source

Use memset instead of nested for-loop to zero a 2d array

Saves 26 bytes of flash memory and removes two 'int' types
Guðni Már Gilbert 2 years ago
parent
commit
a54a133968
1 changed files with 1 additions and 3 deletions
  1. 1 3
      Firmware/mesh_bed_leveling.cpp

+ 1 - 3
Firmware/mesh_bed_leveling.cpp

@@ -10,9 +10,7 @@ mesh_bed_leveling::mesh_bed_leveling() { reset(); }
 
 void mesh_bed_leveling::reset() {
     active = 0;
-    for (int y = 0; y < MESH_NUM_Y_POINTS; y++)
-        for (int x = 0; x < MESH_NUM_X_POINTS; x++)
-            z_values[y][x] = 0;
+    memset(z_values, 0, sizeof(float) * MESH_NUM_X_POINTS * MESH_NUM_Y_POINTS);
 }
 
 static inline bool vec_undef(const float v[2])