save 1440 bytes (#2226)

This commit is contained in:
Matthew Kennedy 2021-01-16 18:22:30 -08:00 committed by GitHub
parent 99fcf11cc9
commit 6a1b9db952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -361,10 +361,10 @@ void TriggerWaveform::setTriggerSynchronizationGap3(int gapIndex, float syncRati
/**
* this method is only used on initialization
*/
int TriggerWaveform::findAngleIndex(TriggerFormDetails *details, float target) const {
int engineCycleEventCount = getLength();
uint16_t TriggerWaveform::findAngleIndex(TriggerFormDetails *details, float target) const {
size_t engineCycleEventCount = getLength();
efiAssert(CUSTOM_ERR_ASSERT, engineCycleEventCount > 0, "engineCycleEventCount", 0);
efiAssert(CUSTOM_ERR_ASSERT, engineCycleEventCount <= 0xFFFF, "engineCycleEventCount", 0);
uint32_t left = 0;
uint32_t right = engineCycleEventCount - 1;
@ -433,11 +433,13 @@ void TriggerWaveform::prepareShape(TriggerFormDetails *details DECLARE_ENGINE_PA
int engineCycleInt = (int) getEngineCycle(operationMode);
for (int angle = 0; angle < engineCycleInt; angle++) {
int triggerShapeIndex = findAngleIndex(details, angle);
uint16_t triggerShapeIndex = findAngleIndex(details, angle);
if (useOnlyRisingEdgeForTriggerTemp) {
// we need even index for front_only mode - so if odd indexes are rounded down
triggerShapeIndex = triggerShapeIndex & 0xFFFFFFFE;
// we need even index for front_only mode - so if odd indexes are rounded down by clearing the low bit
triggerShapeIndex &= 0xFFFE;
}
details->triggerIndexByAngle[angle] = triggerShapeIndex;
}
#endif

View File

@ -275,7 +275,7 @@ public:
private:
trigger_shape_helper h;
int findAngleIndex(TriggerFormDetails *details, float angle) const;
uint16_t findAngleIndex(TriggerFormDetails *details, float angle) const;
/**
* Working buffer for 'wave' instance
@ -313,7 +313,7 @@ public:
* this cache allows us to find a close-enough (with one degree precision) trigger wheel index by
* given angle with fast constant speed. That's a performance optimization for event scheduling.
*/
int triggerIndexByAngle[720];
uint16_t triggerIndexByAngle[720];
};
void findTriggerPosition(