mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-16 02:02:51 -07:00
Updating HistoryViewModel::SaveHistory so it (#819)
Taking a const ref of history items vector in HistoryViewModel::SaveHistory and iterating over those items using a range for loop.
This commit is contained in:
parent
369843dd37
commit
d0785b2fad
1 changed files with 3 additions and 3 deletions
|
@ -267,16 +267,16 @@ void HistoryViewModel::ClearHistory()
|
||||||
void HistoryViewModel::SaveHistory()
|
void HistoryViewModel::SaveHistory()
|
||||||
{
|
{
|
||||||
ApplicationDataContainer ^ historyContainer = GetHistoryContainer(m_currentMode);
|
ApplicationDataContainer ^ historyContainer = GetHistoryContainer(m_currentMode);
|
||||||
auto currentHistoryVector = m_calculatorManager->GetHistoryItems(m_currentMode);
|
auto const& currentHistoryVector = m_calculatorManager->GetHistoryItems(m_currentMode);
|
||||||
bool failure = false;
|
bool failure = false;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
Platform::String ^ serializedHistoryItem;
|
Platform::String ^ serializedHistoryItem;
|
||||||
|
|
||||||
for (auto iter = currentHistoryVector.begin(); iter != currentHistoryVector.end(); ++iter)
|
for (auto const& item : currentHistoryVector)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serializedHistoryItem = SerializeHistoryItem(*iter);
|
serializedHistoryItem = SerializeHistoryItem(item);
|
||||||
historyContainer->Values->Insert(index.ToString(), serializedHistoryItem);
|
historyContainer->Values->Insert(index.ToString(), serializedHistoryItem);
|
||||||
}
|
}
|
||||||
catch (Platform::Exception ^)
|
catch (Platform::Exception ^)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue