From 68c7159c87e67649b1650ab19e203c4447bbed1f Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Sun, 2 Oct 2022 17:19:40 -0400 Subject: [PATCH] Refactor CopyPasteManager (#1918) Get the object reference and use that instead of accessing the array twice to get the object --- src/CalcViewModel/Common/CopyPasteManager.cpp | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/CalcViewModel/Common/CopyPasteManager.cpp b/src/CalcViewModel/Common/CopyPasteManager.cpp index 1e09072a..d7f85dde 100644 --- a/src/CalcViewModel/Common/CopyPasteManager.cpp +++ b/src/CalcViewModel/Common/CopyPasteManager.cpp @@ -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(programmerNumberBase) - static_cast(NumberBase::HexBase)]; + patterns.assign(pattern->begin(), pattern->end()); } else if (modeType == CategoryGroupType::Converter) { @@ -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; } }