瀏覽代碼

Explicitly optimize x/x in Classic Jerk (#18112)

Can we outsmart the compiler?
XDA-Bam 4 年之前
父節點
當前提交
5fbea83840
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 8 行新增8 行删除
  1. 8
    8
      Marlin/src/module/planner.cpp

+ 8
- 8
Marlin/src/module/planner.cpp 查看文件

@@ -2456,16 +2456,16 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2456 2456
       // Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
2457 2457
       CACHED_SQRT(previous_nominal_speed, previous_nominal_speed_sqr);
2458 2458
 
2459
-      vmax_junction = _MIN(nominal_speed, previous_nominal_speed);
2459
+      float smaller_speed_factor = 1.0f;
2460
+      if (nominal_speed < previous_nominal_speed) {
2461
+        vmax_junction = nominal_speed;
2462
+        smaller_speed_factor = vmax_junction / previous_nominal_speed;
2463
+      }
2464
+      else
2465
+        vmax_junction = previous_nominal_speed;
2460 2466
 
2461 2467
       // Now limit the jerk in all axes.
2462
-      const float smaller_speed_factor = vmax_junction / previous_nominal_speed;
2463
-      #if HAS_LINEAR_E_JERK
2464
-        LOOP_XYZ(axis)
2465
-      #else
2466
-        LOOP_XYZE(axis)
2467
-      #endif
2468
-      {
2468
+      TERN(HAS_LINEAR_E_JERK, LOOP_XYZ, LOOP_XYZE)(axis) {
2469 2469
         // Limit an axis. We have to differentiate: coasting, reversal of an axis, full stop.
2470 2470
         float v_exit = previous_speed[axis] * smaller_speed_factor,
2471 2471
               v_entry = current_speed[axis];

Loading…
取消
儲存