mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
Improve coding style
This commit is contained in:
parent
e6a80f28eb
commit
4fff486c5c
2 changed files with 8 additions and 6 deletions
|
@ -407,6 +407,7 @@ void UnitConverter::RestoreUserPreferences(const wstring& userPreferences)
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto fromType = StringToUnit(outerTokens[0]);
|
||||
auto toType = StringToUnit(outerTokens[1]);
|
||||
m_currentCategory = StringToCategory(outerTokens[2]);
|
||||
|
@ -415,7 +416,7 @@ void UnitConverter::RestoreUserPreferences(const wstring& userPreferences)
|
|||
auto itr = m_categoryToUnits.find(m_currentCategory);
|
||||
if (itr != m_categoryToUnits.end())
|
||||
{
|
||||
auto curUnits = itr->second;
|
||||
const auto& curUnits = itr->second;
|
||||
if (find(curUnits.begin(), curUnits.end(), fromType) != curUnits.end())
|
||||
{
|
||||
m_fromType = fromType;
|
||||
|
|
|
@ -118,18 +118,19 @@ void UnitConverterDataLoader::LoadData()
|
|||
unordered_map<int, double> unitConversions = categoryToUnitConversionDataMap.at(categoryViewMode);
|
||||
double unitFactor = unitConversions[unit.id];
|
||||
|
||||
for (auto itr = unitConversions.begin(); itr != unitConversions.end(); ++itr)
|
||||
for (const auto&[id, conversionFactor] : unitConversions)
|
||||
{
|
||||
if (idToUnit.find(itr->first) == idToUnit.end())
|
||||
if (idToUnit.find(id) == idToUnit.end())
|
||||
{
|
||||
// Optional units will not be in idToUnit but can be in unitConversions.
|
||||
// For optional units that did not make it to the current set of units, just continue.
|
||||
continue;
|
||||
}
|
||||
|
||||
UCM::ConversionData parsedData = { 1.0, 0.0, false };
|
||||
assert(itr->second > 0); // divide by zero assert
|
||||
parsedData.ratio = unitFactor / itr->second;
|
||||
conversions.insert(pair<UCM::Unit, UCM::ConversionData>(idToUnit.at(itr->first), parsedData));
|
||||
assert(conversionFactor > 0); // divide by zero assert
|
||||
parsedData.ratio = unitFactor / conversionFactor;
|
||||
conversions.insert(pair<UCM::Unit, UCM::ConversionData>(idToUnit.at(id), parsedData));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue