Making string concatenations more efficent (#760)

by appending wchar_ts instead of  wstrings
This commit is contained in:
Scott Freeman 2019-10-31 14:44:25 -04:00 committed by Matt Cooley
parent 6366e0c535
commit 5e46ceabc8
2 changed files with 7 additions and 9 deletions

View File

@ -223,20 +223,20 @@ const wstring& COpndCommand::GetToken(wchar_t decimalSymbol)
if (nOpCode == IDC_PNT) if (nOpCode == IDC_PNT)
{ {
m_token.append(wstring{ decimalSymbol }); m_token += decimalSymbol;
} }
else if (nOpCode == IDC_EXP) else if (nOpCode == IDC_EXP)
{ {
m_token.append(&chExp); m_token += chExp;
int nextOpCode = m_commands->at(i + 1); int nextOpCode = m_commands->at(i + 1);
if (nextOpCode != IDC_SIGN) if (nextOpCode != IDC_SIGN)
{ {
m_token.append(&chPlus); m_token += chPlus;
} }
} }
else if (nOpCode == IDC_SIGN) else if (nOpCode == IDC_SIGN)
{ {
m_token.append(&chNegate); m_token += chNegate;
} }
else else
{ {
@ -261,15 +261,14 @@ const wstring& COpndCommand::GetToken(wchar_t decimalSymbol)
if (m_fNegative) if (m_fNegative)
{ {
m_token.insert(0, &chNegate); m_token.insert(0, 1, chNegate);
} }
return m_token; return m_token;
} }
} }
m_token.clear(); m_token = chZero;
m_token.append(&chZero);
return m_token; return m_token;
} }

View File

@ -1324,8 +1324,7 @@ void StandardCalculatorViewModel::SaveEditedCommand(_In_ unsigned int tokenPosit
} }
if ((token.first.length() > 0) && (token.first[token.first.length() - 1] == L'(')) if ((token.first.length() > 0) && (token.first[token.first.length() - 1] == L'('))
{ {
wstring chOpenBrace = L"("; updatedToken += L'(';
updatedToken.append(chOpenBrace);
} }
} }
else if (IsBinOp(nOpCode)) else if (IsBinOp(nOpCode))