From a9d0cc5e566fbd8d61887ffc95bb412479150321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 6 May 2023 20:54:42 +0000 Subject: [PATCH] optimisation: Move divison into constexpr Change in memory: Flash: -12 bytes SRAM: 0 bytes --- Firmware/mesh_bed_calibration.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 4808a66f1..464e46e30 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -2186,12 +2186,14 @@ inline void scan_bed_induction_sensor_point() float __attribute__((noinline)) BED_X(const uint8_t col) { - return ((float)col * (BED_Xn - BED_X0) / (MESH_NUM_X_POINTS - 1) + BED_X0); + constexpr float x_mesh_density = (BED_Xn - BED_X0) / (MESH_NUM_X_POINTS - 1); + return ((float)col * x_mesh_density + BED_X0); } float __attribute__((noinline)) BED_Y(const uint8_t row) { - return ((float)row * (BED_Yn - BED_Y0) / (MESH_NUM_Y_POINTS - 1) + BED_Y0); + constexpr float y_mesh_density = (BED_Yn - BED_Y0) / (MESH_NUM_Y_POINTS - 1); + return ((float)row * y_mesh_density + BED_Y0); } BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level, uint8_t &too_far_mask)