Sfoglia il codice sorgente

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 10 anni fa
parent
commit
c66955aaf9
3 ha cambiato i file con 4 aggiunte e 5 eliminazioni
  1. 0
    1
      Marlin/Marlin.h
  2. 3
    3
      Marlin/Marlin_main.cpp
  3. 1
    1
      Marlin/ultralcd.cpp

+ 0
- 1
Marlin/Marlin.h Vedi File

241
   #define CRITICAL_SECTION_END    SREG = _sreg;
241
   #define CRITICAL_SECTION_END    SREG = _sreg;
242
 #endif
242
 #endif
243
 
243
 
244
-extern float homing_feedrate[];
245
 extern bool axis_relative_modes[];
244
 extern bool axis_relative_modes[];
246
 extern int feedrate_multiplier;
245
 extern int feedrate_multiplier;
247
 extern bool volumetric_enabled;
246
 extern bool volumetric_enabled;

+ 3
- 3
Marlin/Marlin_main.cpp Vedi File

246
 static int commands_in_queue = 0;
246
 static int commands_in_queue = 0;
247
 static char command_queue[BUFSIZE][MAX_CMD_SIZE];
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
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
250
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
251
 int feedrate_multiplier = 100; //100->1 200->2
251
 int feedrate_multiplier = 100; //100->1 200->2
252
 int saved_feedrate_multiplier;
252
 int saved_feedrate_multiplier;
310
 #endif
310
 #endif
311
 
311
 
312
 #ifdef SERVO_ENDSTOPS
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
 #endif
315
 #endif
316
 
316
 
317
 #ifdef BARICUDA
317
 #ifdef BARICUDA

+ 1
- 1
Marlin/ultralcd.cpp Vedi File

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

Loading…
Annulla
Salva