Refactor CopyPasteManager (#1918)

Get the object reference and use that instead of accessing the array twice to get the object
This commit is contained in:
Rose 2022-10-02 17:19:40 -04:00 committed by GitHub
parent 3d8576bad6
commit 68c7159c87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -288,9 +288,8 @@ bool CopyPasteManager::ExpressionRegExMatch(
} }
else if (mode == ViewMode::Programmer) else if (mode == ViewMode::Programmer)
{ {
patterns.assign( auto pattern = &programmerModePatterns[static_cast<int>(programmerNumberBase) - static_cast<int>(NumberBase::HexBase)];
programmerModePatterns[(int)programmerNumberBase - (int)NumberBase::HexBase].begin(), patterns.assign(pattern->begin(), pattern->end());
programmerModePatterns[(int)programmerNumberBase - (int)NumberBase::HexBase].end());
} }
else if (modeType == CategoryGroupType::Converter) else if (modeType == CategoryGroupType::Converter)
{ {
@ -505,9 +504,7 @@ ULONG32 CopyPasteManager::StandardScientificOperandLength(Platform::String ^ ope
const bool hasDecimal = operandWstring.find('.') != wstring::npos; const bool hasDecimal = operandWstring.find('.') != wstring::npos;
auto length = operandWstring.length(); 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'.'))
{ {
@ -518,7 +515,6 @@ ULONG32 CopyPasteManager::StandardScientificOperandLength(Platform::String ^ ope
length -= 1; length -= 1;
} }
} }
}
auto exponentPos = operandWstring.find('e'); auto exponentPos = operandWstring.find('e');
const bool hasExponent = exponentPos != wstring::npos; const bool hasExponent = exponentPos != wstring::npos;