Make engine* and friends be const pointers in production. (#3564)
This allows the compiler to see through the pointer and make accesses faster. It saves 1336 bytes of text.
This commit is contained in:
parent
8dbdeb7773
commit
70ad9724c0
|
@ -399,5 +399,7 @@ void doScheduleStopEngine();
|
|||
// These externs aren't needed for unit tests - everything is injected instead
|
||||
#if !EFI_UNIT_TEST
|
||||
extern Engine ___engine;
|
||||
#endif // EFI_UNIT_TEST
|
||||
static Engine * const engine = &___engine;
|
||||
#else // EFI_UNIT_TEST
|
||||
extern Engine *engine;
|
||||
#endif // EFI_UNIT_TEST
|
||||
|
|
|
@ -129,8 +129,6 @@ static engine_configuration_s activeConfigurationLocalStorage;
|
|||
engine_configuration_s & activeConfiguration = activeConfigurationLocalStorage;
|
||||
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
|
||||
|
||||
extern engine_configuration_s *engineConfiguration;
|
||||
|
||||
void rememberCurrentConfiguration() {
|
||||
#if ! EFI_ACTIVE_CONFIGURATION_IN_FLASH
|
||||
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
|
||||
|
|
|
@ -65,9 +65,13 @@ void setBoardConfigOverrides(void);
|
|||
|
||||
#if !EFI_UNIT_TEST
|
||||
extern persistent_config_container_s persistentState;
|
||||
#endif // EFI_UNIT_TEST
|
||||
static engine_configuration_s * const engineConfiguration =
|
||||
&persistentState.persistentConfiguration.engineConfiguration;
|
||||
static persistent_config_s * const config = &persistentState.persistentConfiguration;
|
||||
#else // EFI_UNIT_TEST
|
||||
extern engine_configuration_s *engineConfiguration;
|
||||
extern persistent_config_s *config;
|
||||
#endif // EFI_UNIT_TEST
|
||||
|
||||
/**
|
||||
* & is reference in C++ (not C)
|
||||
|
|
|
@ -98,7 +98,6 @@
|
|||
* Would love to pass reference to configuration object into constructor but C++ does allow attributes after parenthesized initializer
|
||||
*/
|
||||
Engine ___engine CCM_OPTIONAL;
|
||||
Engine * engine = &___engine;
|
||||
|
||||
#else // EFI_UNIT_TEST
|
||||
|
||||
|
|
|
@ -29,10 +29,6 @@
|
|||
|
||||
static bool needToWriteConfiguration = false;
|
||||
|
||||
extern persistent_config_container_s persistentState;
|
||||
|
||||
extern engine_configuration_s *engineConfiguration;
|
||||
|
||||
/* if we store settings externally */
|
||||
#if EFI_STORAGE_EXT_SNOR == TRUE
|
||||
|
||||
|
|
|
@ -29,15 +29,6 @@
|
|||
|
||||
persistent_config_container_s persistentState CCM_OPTIONAL;
|
||||
|
||||
persistent_config_s *config = &persistentState.persistentConfiguration;
|
||||
|
||||
/**
|
||||
* todo: it really looks like these fields should become 'static', i.e. private
|
||||
* the whole 'extern ...' pattern is less then perfect, I guess the 'God object' Engine
|
||||
* would be a smaller evil. Whatever is needed should be passed into methods/modules/files as an explicit parameter.
|
||||
*/
|
||||
engine_configuration_s *engineConfiguration = &persistentState.persistentConfiguration.engineConfiguration;
|
||||
|
||||
#else // EFI_UNIT_TEST
|
||||
|
||||
persistent_config_s * config;
|
||||
|
|
|
@ -50,8 +50,6 @@ void printSpiState(const engine_configuration_s *engineConfiguration) {
|
|||
boolToString(engineConfiguration->is_enabled_spi_4));
|
||||
}
|
||||
|
||||
extern engine_configuration_s *engineConfiguration;
|
||||
|
||||
static void printOutputs(const engine_configuration_s *engineConfiguration) {
|
||||
efiPrintf("injectionPins: mode %s", getPin_output_mode_e(engineConfiguration->injectionPinMode));
|
||||
for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
|
@ -1220,7 +1218,7 @@ void initSettings(void) {
|
|||
|
||||
// todo: start saving values into flash right away?
|
||||
|
||||
addConsoleActionP("showconfig", (VoidPtr) doPrintConfiguration, &engine);
|
||||
addConsoleAction("showconfig", doPrintConfiguration);
|
||||
addConsoleAction("tempinfo", printTemperatureInfo);
|
||||
addConsoleAction("tpsinfo", printTPSInfo);
|
||||
addConsoleAction("calibrate_tps_1_closed", grabTPSIsClosed);
|
||||
|
|
Loading…
Reference in New Issue