From 0cdc4826155333b5a5a914f3e760e06269045ac4 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Mon, 15 Aug 2022 08:42:25 +0200 Subject: [PATCH] Optimization: Replaced lrint() with round() as lrint() cannot be inlined, at least not on MSVC. --- src/libslic3r/GCodeWriter.cpp | 4 ++-- src/libslic3r/Point.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index c5279c0f5..c2caf5766 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -23,8 +23,8 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config) bool use_mach_limits = print_config.gcode_flavor.value == gcfMarlinLegacy || print_config.gcode_flavor.value == gcfMarlinFirmware || print_config.gcode_flavor.value == gcfRepRapFirmware; - m_max_acceleration = std::lrint((use_mach_limits && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) ? - print_config.machine_max_acceleration_extruding.values.front() : 0); + m_max_acceleration = static_cast(std::round((use_mach_limits && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) ? + print_config.machine_max_acceleration_extruding.values.front() : 0)); } void GCodeWriter::set_extruders(std::vector extruder_ids) diff --git a/src/libslic3r/Point.hpp b/src/libslic3r/Point.hpp index 77d99d14a..7fb04530f 100644 --- a/src/libslic3r/Point.hpp +++ b/src/libslic3r/Point.hpp @@ -141,9 +141,9 @@ public: Point() : Vec2crd(0, 0) {} Point(int32_t x, int32_t y) : Vec2crd(coord_t(x), coord_t(y)) {} Point(int64_t x, int64_t y) : Vec2crd(coord_t(x), coord_t(y)) {} - Point(double x, double y) : Vec2crd(coord_t(lrint(x)), coord_t(lrint(y))) {} + Point(double x, double y) : Vec2crd(coord_t(std::round(x)), coord_t(std::round(y))) {} Point(const Point &rhs) { *this = rhs; } - explicit Point(const Vec2d& rhs) : Vec2crd(coord_t(lrint(rhs.x())), coord_t(lrint(rhs.y()))) {} + explicit Point(const Vec2d& rhs) : Vec2crd(coord_t(std::round(rhs.x())), coord_t(std::round(rhs.y()))) {} // This constructor allows you to construct Point from Eigen expressions template Point(const Eigen::MatrixBase &other) : Vec2crd(other) {}