From c99bd69889ba63320695a2946791c6a9c08ead62 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 22 May 2017 13:55:07 -0500 Subject: [PATCH] Apply const float & more --- Marlin/Marlin_main.cpp | 2 +- Marlin/least_squares_fit.h | 8 ++++---- Marlin/ubl_G29.cpp | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index d8f6f26ec..5e43a01e9 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2355,7 +2355,7 @@ static void clean_up_after_endstop_or_probe_move() { * - Raise to the BETWEEN height * - Return the probed Z position */ - float probe_pt(const float x, const float y, const bool stow/*=true*/, const int verbose_level/*=1*/) { + float probe_pt(const float &x, const float &y, const bool stow/*=true*/, const int verbose_level/*=1*/) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { SERIAL_ECHOPAIR(">>> probe_pt(", x); diff --git a/Marlin/least_squares_fit.h b/Marlin/least_squares_fit.h index 4e0c8a48b..a5da16a8a 100644 --- a/Marlin/least_squares_fit.h +++ b/Marlin/least_squares_fit.h @@ -52,7 +52,7 @@ void inline incremental_LSF_reset(struct linear_fit_data *lsf) { memset(lsf, 0, sizeof(linear_fit_data)); } -void inline incremental_WLSF(struct linear_fit_data *lsf, float x, float y, float z, float w) { +void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) { // weight each accumulator by factor w, including the "number" of samples // (analagous to calling inc_LSF twice with same values to weight it by 2X) lsf->xbar += w * x; @@ -65,11 +65,11 @@ void inline incremental_WLSF(struct linear_fit_data *lsf, float x, float y, floa lsf->xzbar += w * x * z; lsf->yzbar += w * y * z; lsf->N += w; - lsf->max_absx = max(fabs( w * x ), lsf->max_absx); - lsf->max_absy = max(fabs( w * y ), lsf->max_absy); + lsf->max_absx = max(fabs(w * x), lsf->max_absx); + lsf->max_absy = max(fabs(w * y), lsf->max_absy); } -void inline incremental_LSF(struct linear_fit_data *lsf, float x, float y, float z) { +void inline incremental_LSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z) { lsf->xbar += x; lsf->ybar += y; lsf->zbar += z; diff --git a/Marlin/ubl_G29.cpp b/Marlin/ubl_G29.cpp index 506ae6322..c9efd1212 100644 --- a/Marlin/ubl_G29.cpp +++ b/Marlin/ubl_G29.cpp @@ -51,10 +51,10 @@ extern uint8_t code_value_byte(); extern bool code_value_bool(); extern bool code_has_value(); - extern float probe_pt(float x, float y, bool, int); + extern float probe_pt(const float &x, const float &y, bool, int); extern bool set_probe_deployed(bool); void smart_fill_mesh(); - void smart_fill_wlsf(float); + void smart_fill_wlsf(const float &); float measure_business_card_thickness(float &in_height); void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool); @@ -531,7 +531,7 @@ } } else { const float cvf = code_value_float(); - switch( (int)truncf( cvf * 10.0 ) - 30 ) { // 3.1 -> 1 + switch((int)truncf(cvf * 10.0) - 30) { // 3.1 -> 1 #if ENABLED(UBL_G29_P31) case 1: { @@ -541,9 +541,9 @@ // P3.12 100X distance weighting // P3.13 1000X distance weighting, approaches simple average of nearest points - const float weight_power = (cvf - 3.10) * 100.0; // 3.12345 -> 2.345 - const float weight_factor = weight_power ? pow( 10.0, weight_power ) : 0; - smart_fill_wlsf( weight_factor ); + const float weight_power = (cvf - 3.10) * 100.0, // 3.12345 -> 2.345 + weight_factor = weight_power ? pow(10.0, weight_power) : 0; + smart_fill_wlsf(weight_factor); } break; #endif