Propose minor code-cleanups (#241)

Description of the changes:
Remove unnecessary 'else', 'continue' statements

How changes were validated:
Manual.
This commit is contained in:
Shamkhal Maharramov 2019-03-19 00:38:04 +04:00 committed by Howard Wolosky
parent b8b0fdf86b
commit 965e36cc5d

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
#include "pch.h" #include "pch.h"
@ -202,13 +202,11 @@ void UnitConverterViewModel::BuildUnitList(const vector<UCM::Unit>& modelUnitLis
m_Units->Clear(); m_Units->Clear();
for (const UCM::Unit& modelUnit : modelUnitList) for (const UCM::Unit& modelUnit : modelUnitList)
{ {
if (modelUnit.isWhimsical) if (!modelUnit.isWhimsical)
{ {
continue;
}
m_Units->Append(ref new Unit(modelUnit)); m_Units->Append(ref new Unit(modelUnit));
} }
}
if (m_Units->Size == 0) if (m_Units->Size == 0)
{ {
@ -643,11 +641,9 @@ String^ UnitConverterViewModel::Serialize()
String^ serializedData = ref new String(wstring(out.str()).c_str()); String^ serializedData = ref new String(wstring(out.str()).c_str());
return serializedData; return serializedData;
} }
else
{
return nullptr; return nullptr;
} }
}
void UnitConverterViewModel::Deserialize(Platform::String^ state) void UnitConverterViewModel::Deserialize(Platform::String^ state)
{ {
@ -879,14 +875,11 @@ void UnitConverterViewModel::UpdateInputBlocked(_In_ const wstring& currencyInpu
{ {
// currencyInput is in en-US and has the default decimal separator, so this is safe to do. // currencyInput is in en-US and has the default decimal separator, so this is safe to do.
auto posOfDecimal = currencyInput.find(L'.'); auto posOfDecimal = currencyInput.find(L'.');
m_isInputBlocked = false;
if (posOfDecimal != wstring::npos && IsCurrencyCurrentCategory) if (posOfDecimal != wstring::npos && IsCurrencyCurrentCategory)
{ {
m_isInputBlocked = (posOfDecimal + static_cast<size_t>(m_currencyMaxFractionDigits) + 1 == currencyInput.length()); m_isInputBlocked = (posOfDecimal + static_cast<size_t>(m_currencyMaxFractionDigits) + 1 == currencyInput.length());
} }
else
{
m_isInputBlocked = false;
}
} }
NumbersAndOperatorsEnum UnitConverterViewModel::MapCharacterToButtonId( NumbersAndOperatorsEnum UnitConverterViewModel::MapCharacterToButtonId(
@ -988,7 +981,7 @@ void UnitConverterViewModel::OnPaste(String^ stringToPaste, ViewMode mode)
} }
// Negate is only allowed if it's the first legal character, which is handled above. // Negate is only allowed if it's the first legal character, which is handled above.
if (NumbersAndOperatorsEnum::None != op && NumbersAndOperatorsEnum::Negate != op) if (NumbersAndOperatorsEnum::Negate != op)
{ {
UCM::Command cmd = CommandFromButtonId(op); UCM::Command cmd = CommandFromButtonId(op);
m_model->SendCommand(cmd); m_model->SendCommand(cmd);