Move the CalculatorManager instance to be direct member data of the StandardCalculatorViewModel class.

Previously, the CalculatorManager was managed with a unique_ptr that was instantiated in the ViewModel's constructor and was never re-assigned.  Objects with long lifetime and larger memory footprint should live in dynamic memory, but the ViewModel itself lives in dynamic memory so that goal is still satisfied by storing the CalculatorManager directly in the class. The change allows the compiler to write a more efficient memory footprint for the same data.

- Verified by testing basic app functionality and running unit tests locally.
This commit is contained in:
Daniel Belcher 2019-02-28 14:16:02 -08:00
parent d6917f5664
commit dd79d6fcd3
4 changed files with 197 additions and 197 deletions

View file

@ -214,7 +214,7 @@ namespace CalculatorApp
}
property bool IsEngineRecording {
bool get() { return m_standardCalculatorManager->IsEngineRecording(); }
bool get() { return m_standardCalculatorManager.IsEngineRecording(); }
}
property bool IsOperandEnabled {
@ -311,7 +311,7 @@ namespace CalculatorApp
void ResetDisplay();
RADIX_TYPE GetCurrentRadixType() { return (RADIX_TYPE)m_CurrentRadixType; }
void SetPrecision(int32_t precision);
void UpdateMaxIntDigits() { m_standardCalculatorManager->UpdateMaxIntDigits(); }
void UpdateMaxIntDigits() { m_standardCalculatorManager.UpdateMaxIntDigits(); }
NumbersAndOperatorsEnum GetCurrentAngleType() { return m_CurrentAngleType; }
private:
@ -323,7 +323,7 @@ namespace CalculatorApp
wchar_t m_decimalSeparator;
CalculatorDisplay m_calculatorDisplay;
CalculatorApp::EngineResourceProvider m_resourceProvider;
std::unique_ptr<CalculationManager::CalculatorManager> m_standardCalculatorManager;
CalculationManager::CalculatorManager m_standardCalculatorManager;
Platform::String^ m_expressionAutomationNameFormat;
Platform::String^ m_localizedCalculationResultAutomationFormat;
Platform::String^ m_localizedCalculationResultDecimalAutomationFormat;