Skip to content

Commit

Permalink
Refactor CopyPasteManager (#1918)
Browse files Browse the repository at this point in the history
Get the object reference and use that instead of accessing the array twice to get the object
  • Loading branch information
AZero13 authored Oct 2, 2022
1 parent 3d8576b commit 68c7159
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/CalcViewModel/Common/CopyPasteManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,8 @@ bool CopyPasteManager::ExpressionRegExMatch(
}
else if (mode == ViewMode::Programmer)
{
patterns.assign(
programmerModePatterns[(int)programmerNumberBase - (int)NumberBase::HexBase].begin(),
programmerModePatterns[(int)programmerNumberBase - (int)NumberBase::HexBase].end());
auto pattern = &programmerModePatterns[static_cast<int>(programmerNumberBase) - static_cast<int>(NumberBase::HexBase)];
patterns.assign(pattern->begin(), pattern->end());
}
else if (modeType == CategoryGroupType::Converter)
{
Expand Down Expand Up @@ -505,18 +504,15 @@ ULONG32 CopyPasteManager::StandardScientificOperandLength(Platform::String ^ ope
const bool hasDecimal = operandWstring.find('.') != wstring::npos;
auto length = operandWstring.length();

if (hasDecimal)
if (hasDecimal && length >= 2)
{
if (length >= 2)
if ((operandWstring[0] == L'0') && (operandWstring[1] == L'.'))
{
if ((operandWstring[0] == L'0') && (operandWstring[1] == L'.'))
{
length -= 2;
}
else
{
length -= 1;
}
length -= 2;
}
else
{
length -= 1;
}
}

Expand Down

0 comments on commit 68c7159

Please sign in to comment.