Selaa lähdekoodia

Mark unchanging arrays as const (PR#2494)

The compiler may be able to optimize if it knows an array won’t be
changing.
Scott Lahteine 9 vuotta sitten
vanhempi
commit
c66955aaf9
3 muutettua tiedostoa jossa 4 lisäystä ja 5 poistoa
  1. 0
    1
      Marlin/Marlin.h
  2. 3
    3
      Marlin/Marlin_main.cpp
  3. 1
    1
      Marlin/ultralcd.cpp

+ 0
- 1
Marlin/Marlin.h Näytä tiedosto

@@ -241,7 +241,6 @@ inline void refresh_cmd_timeout() { previous_cmd_ms = millis(); }
241 241
   #define CRITICAL_SECTION_END    SREG = _sreg;
242 242
 #endif
243 243
 
244
-extern float homing_feedrate[];
245 244
 extern bool axis_relative_modes[];
246 245
 extern int feedrate_multiplier;
247 246
 extern bool volumetric_enabled;

+ 3
- 3
Marlin/Marlin_main.cpp Näytä tiedosto

@@ -246,7 +246,7 @@ static int cmd_queue_index_w = 0;
246 246
 static int commands_in_queue = 0;
247 247
 static char command_queue[BUFSIZE][MAX_CMD_SIZE];
248 248
 
249
-float homing_feedrate[] = HOMING_FEEDRATE;
249
+const float homing_feedrate[] = HOMING_FEEDRATE;
250 250
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
251 251
 int feedrate_multiplier = 100; //100->1 200->2
252 252
 int saved_feedrate_multiplier;
@@ -310,8 +310,8 @@ bool target_direction;
310 310
 #endif
311 311
 
312 312
 #ifdef SERVO_ENDSTOPS
313
-  int servo_endstops[] = SERVO_ENDSTOPS;
314
-  int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES;
313
+  const int servo_endstops[] = SERVO_ENDSTOPS;
314
+  const int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES;
315 315
 #endif
316 316
 
317 317
 #ifdef BARICUDA

+ 1
- 1
Marlin/ultralcd.cpp Näytä tiedosto

@@ -44,7 +44,7 @@ static void lcd_status_screen();
44 44
   #if HAS_POWER_SWITCH
45 45
     extern bool powersupply;
46 46
   #endif
47
-  static float manual_feedrate[] = MANUAL_FEEDRATE;
47
+  const float manual_feedrate[] = MANUAL_FEEDRATE;
48 48
   static void lcd_main_menu();
49 49
   static void lcd_tune_menu();
50 50
   static void lcd_prepare_menu();

Loading…
Peruuta
Tallenna