Skip to content

Commit 68c7159

Browse files
authored
Refactor CopyPasteManager (#1918)
Get the object reference and use that instead of accessing the array twice to get the object
1 parent 3d8576b commit 68c7159

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/CalcViewModel/Common/CopyPasteManager.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,8 @@ bool CopyPasteManager::ExpressionRegExMatch(
288288
}
289289
else if (mode == ViewMode::Programmer)
290290
{
291-
patterns.assign(
292-
programmerModePatterns[(int)programmerNumberBase - (int)NumberBase::HexBase].begin(),
293-
programmerModePatterns[(int)programmerNumberBase - (int)NumberBase::HexBase].end());
291+
auto pattern = &programmerModePatterns[static_cast<int>(programmerNumberBase) - static_cast<int>(NumberBase::HexBase)];
292+
patterns.assign(pattern->begin(), pattern->end());
294293
}
295294
else if (modeType == CategoryGroupType::Converter)
296295
{
@@ -505,18 +504,15 @@ ULONG32 CopyPasteManager::StandardScientificOperandLength(Platform::String ^ ope
505504
const bool hasDecimal = operandWstring.find('.') != wstring::npos;
506505
auto length = operandWstring.length();
507506

508-
if (hasDecimal)
507+
if (hasDecimal && length >= 2)
509508
{
510-
if (length >= 2)
509+
if ((operandWstring[0] == L'0') && (operandWstring[1] == L'.'))
511510
{
512-
if ((operandWstring[0] == L'0') && (operandWstring[1] == L'.'))
513-
{
514-
length -= 2;
515-
}
516-
else
517-
{
518-
length -= 1;
519-
}
511+
length -= 2;
512+
}
513+
else
514+
{
515+
length -= 1;
520516
}
521517
}
522518

0 commit comments

Comments
 (0)