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:
		
				
					committed by
					
						
						Matt Cooley
					
				
			
			
				
	
			
			
			
						parent
						
							369843dd37
						
					
				
				
					commit
					d0785b2fad
				
			@@ -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 ^)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user