From 5e46ceabc80ce7c51506fbf960c544fb3e75b69b Mon Sep 17 00:00:00 2001 From: Scott Freeman Date: Thu, 31 Oct 2019 14:44:25 -0400 Subject: [PATCH] Making string concatenations more efficent (#760) by appending wchar_ts instead of wstrings --- src/CalcManager/ExpressionCommand.cpp | 13 ++++++------- src/CalcViewModel/StandardCalculatorViewModel.cpp | 3 +-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/CalcManager/ExpressionCommand.cpp b/src/CalcManager/ExpressionCommand.cpp index d6d9ae0e..885a938c 100644 --- a/src/CalcManager/ExpressionCommand.cpp +++ b/src/CalcManager/ExpressionCommand.cpp @@ -223,20 +223,20 @@ const wstring& COpndCommand::GetToken(wchar_t decimalSymbol) if (nOpCode == IDC_PNT) { - m_token.append(wstring{ decimalSymbol }); + m_token += decimalSymbol; } else if (nOpCode == IDC_EXP) { - m_token.append(&chExp); + m_token += chExp; int nextOpCode = m_commands->at(i + 1); if (nextOpCode != IDC_SIGN) { - m_token.append(&chPlus); + m_token += chPlus; } } else if (nOpCode == IDC_SIGN) { - m_token.append(&chNegate); + m_token += chNegate; } else { @@ -261,15 +261,14 @@ const wstring& COpndCommand::GetToken(wchar_t decimalSymbol) if (m_fNegative) { - m_token.insert(0, &chNegate); + m_token.insert(0, 1, chNegate); } return m_token; } } - m_token.clear(); - m_token.append(&chZero); + m_token = chZero; return m_token; } diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp index 80414603..594db452 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -1324,8 +1324,7 @@ void StandardCalculatorViewModel::SaveEditedCommand(_In_ unsigned int tokenPosit } if ((token.first.length() > 0) && (token.first[token.first.length() - 1] == L'(')) { - wstring chOpenBrace = L"("; - updatedToken.append(chOpenBrace); + updatedToken += L'('; } } else if (IsBinOp(nOpCode))