Skip to content

Commit d99894c

Browse files
committed
Try out fast types
1 parent e7a2bab commit d99894c

33 files changed

+153
-153
lines changed

Marlin/src/core/macros.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@
375375
#define _JOIN_1(O) (O)
376376
#define JOIN_N(N,C,V...) (DO(JOIN,C,LIST_N(N,V)))
377377

378-
#define LOOP_S_LE_N(VAR, S, N) for (uint8_t VAR=(S); VAR<=(N); VAR++)
379-
#define LOOP_S_L_N(VAR, S, N) for (uint8_t VAR=(S); VAR<(N); VAR++)
378+
#define LOOP_S_LE_N(VAR, S, N) for (uint_fast8_t VAR=(S); VAR<=(N); VAR++)
379+
#define LOOP_S_L_N(VAR, S, N) for (uint_fast8_t VAR=(S); VAR<(N); VAR++)
380380
#define LOOP_LE_N(VAR, N) LOOP_S_LE_N(VAR, 0, N)
381381
#define LOOP_L_N(VAR, N) LOOP_S_L_N(VAR, 0, N)
382382

Marlin/src/core/types.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ typedef struct AxisFlags {
161161
// - A_AXIS, B_AXIS, and C_AXIS should be used for Steppers, corresponding to XYZ on Cartesians
162162
// - X_HEAD, Y_HEAD, and Z_HEAD should be used for Steppers on Core kinematics
163163
//
164-
enum AxisEnum : uint8_t {
164+
enum AxisEnum : uint_fast8_t {
165165

166166
// Linear axes may be controlled directly or indirectly
167167
NUM_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS, U_AXIS, V_AXIS, W_AXIS)

Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ void unified_bed_leveling::G29() {
307307
const uint8_t p_val = parser.byteval('P');
308308
const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen_test('J');
309309
#if HAS_MULTI_HOTEND
310-
const uint8_t old_tool_index = active_extruder;
310+
const uint_fast8_t old_tool_index = active_extruder;
311311
#endif
312312

313313
// Check for commands that require the printer to be homed

Marlin/src/feature/pause.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
227227
if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_LOAD, mode);
228228

229229
#if ENABLED(DUAL_X_CARRIAGE)
230-
const int8_t saved_ext = active_extruder;
230+
const int_fast8_t saved_ext = active_extruder;
231231
const bool saved_ext_dup_mode = extruder_duplication_enabled;
232232
set_duplication_enabled(false, DXC_ext);
233233
#endif
@@ -463,7 +463,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
463463
TERN_(DWIN_LCD_PROUI, if (!do_park) ui.set_status(GET_TEXT_F(MSG_PARK_FAILED)));
464464

465465
#if ENABLED(DUAL_X_CARRIAGE)
466-
const int8_t saved_ext = active_extruder;
466+
const int_fast8_t saved_ext = active_extruder;
467467
const bool saved_ext_dup_mode = extruder_duplication_enabled;
468468
set_duplication_enabled(false, DXC_ext);
469469
#endif
@@ -518,7 +518,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
518518
HOTEND_LOOP() thermalManager.heater_idle[e].start(nozzle_timeout);
519519

520520
#if ENABLED(DUAL_X_CARRIAGE)
521-
const int8_t saved_ext = active_extruder;
521+
const int_fast8_t saved_ext = active_extruder;
522522
const bool saved_ext_dup_mode = extruder_duplication_enabled;
523523
set_duplication_enabled(false, DXC_ext);
524524
#endif

Marlin/src/feature/runout.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ class TFilamentMonitor : public FilamentMonitorBase {
134134
}
135135
#else
136136
const bool ran_out = TEST(runout_flags, active_extruder); // suppress non active extruders
137-
uint8_t extruder = active_extruder;
137+
uint_fast8_t extruder = active_extruder;
138138
#endif
139139
#else
140140
const bool ran_out = !!runout_flags;
141-
uint8_t extruder = active_extruder;
141+
uint_fast8_t extruder = active_extruder;
142142
#endif
143143

144144
#if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)

Marlin/src/gcode/bedlevel/G35.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void GcodeSuite::G35() {
8888

8989
// Always home with tool 0 active
9090
#if HAS_MULTI_HOTEND
91-
const uint8_t old_tool_index = active_extruder;
91+
const uint_fast8_t old_tool_index = active_extruder;
9292
tool_change(0, true);
9393
#endif
9494

Marlin/src/gcode/calibrate/G28.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ void GcodeSuite::G28() {
341341
// Always home with tool 0 active
342342
#if HAS_MULTI_HOTEND
343343
#if DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE)
344-
const uint8_t old_tool_index = active_extruder;
344+
const uint_fast8_t old_tool_index = active_extruder;
345345
#endif
346346
// PARKING_EXTRUDER homing requires different handling of movement / solenoid activation, depending on the side of homing
347347
#if ENABLED(PARKING_EXTRUDER)

Marlin/src/gcode/calibrate/G33.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ enum CalEnum : char { // the 7 main calibration points -
6464
#define LOOP_CAL_ACT(VAR, _4P, _OP) LOOP_CAL_PT(VAR, _OP ? _AB : __A, _4P ? _4P_STEP : _7P_STEP)
6565

6666
#if HAS_MULTI_HOTEND
67-
const uint8_t old_tool_index = active_extruder;
67+
const uint_fast8_t old_tool_index = active_extruder;
6868
#endif
6969

7070
float lcd_probe_pt(const xy_pos_t &xy);

Marlin/src/gcode/calibrate/G34_M422.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void GcodeSuite::G34() {
144144

145145
// Always home with tool 0 active
146146
#if HAS_MULTI_HOTEND
147-
const uint8_t old_tool_index = active_extruder;
147+
const uint_fast8_t old_tool_index = active_extruder;
148148
tool_change(0, true);
149149
#endif
150150

Marlin/src/gcode/config/M200-M205.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
if (!parser.seen("DST" TERN_(VOLUMETRIC_EXTRUDER_LIMIT, "L")))
4242
return M200_report();
4343

44-
const int8_t target_extruder = get_target_extruder_from_command();
44+
const int_fast8_t target_extruder = get_target_extruder_from_command();
4545
if (target_extruder < 0) return;
4646

4747
bool vol_enable = parser.volumetric_enabled,
@@ -125,7 +125,7 @@ void GcodeSuite::M201() {
125125
if (!parser.seen("T" STR_AXES_LOGICAL TERN_(XY_FREQUENCY_LIMIT, "FS")))
126126
return M201_report();
127127

128-
const int8_t target_extruder = get_target_extruder_from_command();
128+
const int_fast8_t target_extruder = get_target_extruder_from_command();
129129
if (target_extruder < 0) return;
130130

131131
#ifdef XY_FREQUENCY_LIMIT
@@ -179,7 +179,7 @@ void GcodeSuite::M203() {
179179
if (!parser.seen("T" STR_AXES_LOGICAL))
180180
return M203_report();
181181

182-
const int8_t target_extruder = get_target_extruder_from_command();
182+
const int_fast8_t target_extruder = get_target_extruder_from_command();
183183
if (target_extruder < 0) return;
184184

185185
LOOP_LOGICAL_AXES(i)

Marlin/src/gcode/config/M218.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void GcodeSuite::M218() {
4343

4444
if (!parser.seen_any()) return M218_report();
4545

46-
const int8_t target_extruder = get_target_extruder_from_command();
46+
const int_fast8_t target_extruder = get_target_extruder_from_command();
4747
if (target_extruder < 0) return;
4848

4949
if (parser.seenval('X')) hotend_offset[target_extruder].x = parser.value_linear_units();

Marlin/src/gcode/config/M221.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131
void GcodeSuite::M221() {
3232

33-
const int8_t target_extruder = get_target_extruder_from_command();
33+
const int_fast8_t target_extruder = get_target_extruder_from_command();
3434
if (target_extruder < 0) return;
3535

3636
if (parser.seenval('S'))

Marlin/src/gcode/config/M92.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*/
4040
void GcodeSuite::M92() {
4141

42-
const int8_t target_extruder = get_target_extruder_from_command();
42+
const int_fast8_t target_extruder = get_target_extruder_from_command();
4343
if (target_extruder < 0) return;
4444

4545
// No arguments? Show M92 report.

Marlin/src/gcode/feature/pause/M600.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
void GcodeSuite::M600() {
7474

7575
#if ENABLED(MIXING_EXTRUDER)
76-
const int8_t eindex = get_target_e_stepper_from_command();
76+
const int_fast8_t eindex = get_target_e_stepper_from_command();
7777
if (eindex < 0) return;
7878

7979
const uint8_t old_mixing_tool = mixer.get_current_vtool();
@@ -82,9 +82,9 @@ void GcodeSuite::M600() {
8282
MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0);
8383
mixer.normalize();
8484

85-
const int8_t target_extruder = active_extruder;
85+
const int_fast8_t target_extruder = active_extruder;
8686
#else
87-
const int8_t target_extruder = get_target_extruder_from_command();
87+
const int_fast8_t target_extruder = get_target_extruder_from_command();
8888
if (target_extruder < 0) return;
8989
#endif
9090

@@ -112,7 +112,7 @@ void GcodeSuite::M600() {
112112

113113
#if HAS_MULTI_EXTRUDER
114114
// Change toolhead if specified
115-
const uint8_t active_extruder_before_filament_change = active_extruder;
115+
const uint_fast8_t active_extruder_before_filament_change = active_extruder;
116116
if (active_extruder != target_extruder && TERN1(DUAL_X_CARRIAGE, !idex_is_duplicating()))
117117
tool_change(target_extruder);
118118
#endif

Marlin/src/gcode/feature/pause/M603.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void GcodeSuite::M603() {
4444

4545
if (!parser.seen("TUL")) return M603_report();
4646

47-
const int8_t target_extruder = get_target_extruder_from_command();
47+
const int_fast8_t target_extruder = get_target_extruder_from_command();
4848
if (target_extruder < 0) return;
4949

5050
// Unload length

Marlin/src/gcode/feature/pause/M701_M702.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void GcodeSuite::M701() {
6060
if (TERN0(NO_MOTION_BEFORE_HOMING, axes_should_home())) park_point.z = 0;
6161

6262
#if ENABLED(MIXING_EXTRUDER)
63-
const int8_t eindex = get_target_e_stepper_from_command();
63+
const int_fast8_t eindex = get_target_e_stepper_from_command();
6464
if (eindex < 0) return;
6565

6666
const uint8_t old_mixing_tool = mixer.get_current_vtool();
@@ -69,9 +69,9 @@ void GcodeSuite::M701() {
6969
MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0);
7070
mixer.normalize();
7171

72-
const int8_t target_extruder = active_extruder;
72+
const int_fast8_t target_extruder = active_extruder;
7373
#else
74-
const int8_t target_extruder = get_target_extruder_from_command();
74+
const int_fast8_t target_extruder = get_target_extruder_from_command();
7575
if (target_extruder < 0) return;
7676
#endif
7777

@@ -83,7 +83,7 @@ void GcodeSuite::M701() {
8383

8484
#if HAS_MULTI_EXTRUDER && (HAS_PRUSA_MMU1 || !HAS_MMU)
8585
// Change toolhead if specified
86-
uint8_t active_extruder_before_filament_change = active_extruder;
86+
uint_fast8_t active_extruder_before_filament_change = active_extruder;
8787
if (active_extruder != target_extruder)
8888
tool_change(target_extruder);
8989
#endif
@@ -165,16 +165,16 @@ void GcodeSuite::M702() {
165165
#endif
166166

167167
if (seenT) {
168-
const int8_t eindex = get_target_e_stepper_from_command();
168+
const int_fast8_t eindex = get_target_e_stepper_from_command();
169169
if (eindex < 0) return;
170170
mixer.T(MIXER_DIRECT_SET_TOOL);
171171
MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0);
172172
mixer.normalize();
173173
}
174174

175-
const int8_t target_extruder = active_extruder;
175+
const int_fast8_t target_extruder = active_extruder;
176176
#else
177-
const int8_t target_extruder = get_target_extruder_from_command();
177+
const int_fast8_t target_extruder = get_target_extruder_from_command();
178178
if (target_extruder < 0) return;
179179
#endif
180180

@@ -186,7 +186,7 @@ void GcodeSuite::M702() {
186186

187187
#if HAS_MULTI_EXTRUDER && (HAS_PRUSA_MMU1 || !HAS_MMU)
188188
// Change toolhead if specified
189-
uint8_t active_extruder_before_filament_change = active_extruder;
189+
uint_fast8_t active_extruder_before_filament_change = active_extruder;
190190
if (active_extruder != target_extruder)
191191
tool_change(target_extruder);
192192
#endif

Marlin/src/gcode/feature/trinamic/M906.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void GcodeSuite::M906() {
129129

130130
#if AXIS_IS_TMC(E0) || AXIS_IS_TMC(E1) || AXIS_IS_TMC(E2) || AXIS_IS_TMC(E3) || AXIS_IS_TMC(E4) || AXIS_IS_TMC(E5) || AXIS_IS_TMC(E6) || AXIS_IS_TMC(E7)
131131
case E_AXIS: {
132-
const int8_t eindex = get_target_e_stepper_from_command(-2);
132+
const int_fast8_t eindex = get_target_e_stepper_from_command(-2);
133133
#if AXIS_IS_TMC(E0)
134134
if (eindex < 0 || eindex == 0) TMC_SET_CURRENT(E0);
135135
#endif

Marlin/src/gcode/feature/trinamic/M911-M914.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@
335335

336336
#if E0_HAS_STEALTHCHOP || E1_HAS_STEALTHCHOP || E2_HAS_STEALTHCHOP || E3_HAS_STEALTHCHOP || E4_HAS_STEALTHCHOP || E5_HAS_STEALTHCHOP || E6_HAS_STEALTHCHOP || E7_HAS_STEALTHCHOP
337337
case E_AXIS: {
338-
const int8_t eindex = get_target_e_stepper_from_command(-2);
338+
const int_fast8_t eindex = get_target_e_stepper_from_command(-2);
339339
TERN_(E0_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 0) TMC_SET_PWMTHRS_E(0));
340340
TERN_(E1_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 1) TMC_SET_PWMTHRS_E(1));
341341
TERN_(E2_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 2) TMC_SET_PWMTHRS_E(2));
@@ -345,7 +345,7 @@
345345
TERN_(E6_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 6) TMC_SET_PWMTHRS_E(6));
346346
TERN_(E7_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 7) TMC_SET_PWMTHRS_E(7));
347347
} break;
348-
#endif // E_STEPPERS
348+
#endif
349349
}
350350
}
351351

Marlin/src/gcode/gcode.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void GcodeSuite::say_units() {
134134
* Get the target extruder from the T parameter or the active_extruder
135135
* Return -1 if the T parameter is out of range
136136
*/
137-
int8_t GcodeSuite::get_target_extruder_from_command() {
137+
int_fast8_t GcodeSuite::get_target_extruder_from_command() {
138138
if (parser.seenval('T')) {
139139
const int8_t e = parser.value_byte();
140140
if (e < EXTRUDERS) return e;
@@ -151,7 +151,7 @@ int8_t GcodeSuite::get_target_extruder_from_command() {
151151
* If there is no 'T' parameter then dval will be substituted.
152152
* Returns -1 if the resulting E stepper index is out of range.
153153
*/
154-
int8_t GcodeSuite::get_target_e_stepper_from_command(const int8_t dval/*=-1*/) {
154+
int_fast8_t GcodeSuite::get_target_e_stepper_from_command(const int8_t dval/*=-1*/) {
155155
const int8_t e = parser.intval('T', dval);
156156
if (WITHIN(e, 0, E_STEPPERS - 1)) return e;
157157
if (dval == -2) return dval;

Marlin/src/gcode/gcode.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ class GcodeSuite {
420420
}
421421
static void say_units();
422422

423-
static int8_t get_target_extruder_from_command();
424-
static int8_t get_target_e_stepper_from_command(const int8_t dval=-1);
423+
static int_fast8_t get_target_extruder_from_command();
424+
static int_fast8_t get_target_e_stepper_from_command(const int8_t dval=-1);
425425
static void get_destination_from_command();
426426

427427
static void process_parsed_command(const bool no_ok=false);

Marlin/src/gcode/probe/G30.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
void GcodeSuite::G30() {
5555

5656
#if HAS_MULTI_HOTEND
57-
const uint8_t old_tool_index = active_extruder;
57+
const uint_fast8_t old_tool_index = active_extruder;
5858
tool_change(0);
5959
#endif
6060

Marlin/src/gcode/temp/M104_M109.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ void GcodeSuite::M104_M109(const bool isM109) {
7878
if (DEBUGGING(DRYRUN)) return;
7979

8080
#if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
81-
constexpr int8_t target_extruder = 0;
81+
constexpr int_fast8_t target_extruder = 0;
8282
#else
83-
const int8_t target_extruder = get_target_extruder_from_command();
83+
const int_fast8_t target_extruder = get_target_extruder_from_command();
8484
if (target_extruder < 0) return;
8585
#endif
8686

Marlin/src/gcode/temp/M105.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
void GcodeSuite::M105() {
3030

31-
const int8_t target_extruder = get_target_extruder_from_command();
31+
const int_fast8_t target_extruder = get_target_extruder_from_command();
3232
if (target_extruder < 0) return;
3333

3434
SERIAL_ECHOPGM(STR_OK);

Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va
408408
void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) {
409409
#if HAS_EXTRUDERS
410410
const uint16_t newvalue = BE16_P(val_ptr);
411-
uint8_t target_extruder;
411+
uint_fast8_t target_extruder;
412412
switch (var.VP) {
413413
default: return;
414414
case VP_Flowrate_E0: target_extruder = 0; break;

Marlin/src/module/motion.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ xyze_pos_t destination; // {0}
106106

107107
// The active extruder (tool). Set with T<extruder> command.
108108
#if HAS_MULTI_EXTRUDER
109-
uint8_t active_extruder = 0; // = 0
109+
uint_fast8_t active_extruder = 0; // = 0
110110
#endif
111111

112112
#if ENABLED(LCD_SHOW_E_TOTAL)

Marlin/src/module/motion.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ extern int16_t feedrate_percentage;
109109

110110
// The active extruder (tool). Set with T<extruder> command.
111111
#if HAS_MULTI_EXTRUDER
112-
extern uint8_t active_extruder;
112+
extern uint_fast8_t active_extruder;
113113
#else
114-
constexpr uint8_t active_extruder = 0;
114+
constexpr uint_fast8_t active_extruder = 0;
115115
#endif
116116

117117
#if ENABLED(LCD_SHOW_E_TOTAL)

0 commit comments

Comments
 (0)