From b6b4f41f53bfa415daa39960c9b395147f8c6b18 Mon Sep 17 00:00:00 2001 From: Nicholas Baron Date: Tue, 16 Apr 2019 23:27:54 -0700 Subject: [PATCH] Prevented unneeded copies from being made. Removed an unneeded catch --- src/CalcViewModel/Common/CopyPasteManager.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/CalcViewModel/Common/CopyPasteManager.cpp b/src/CalcViewModel/Common/CopyPasteManager.cpp index a03350e8..39bdca0f 100644 --- a/src/CalcViewModel/Common/CopyPasteManager.cpp +++ b/src/CalcViewModel/Common/CopyPasteManager.cpp @@ -20,7 +20,7 @@ String^ CopyPasteManager::supportedFormats[] = StandardDataFormats::Text }; -constexpr wstring_view c_validCharacterSet{ L"0123456789()+-*/.abcdefABCDEF" }; +static constexpr wstring_view c_validCharacterSet{ L"0123456789()+-*/.abcdefABCDEF" }; // The below values can not be "constexpr"-ed, // as both wstring_view and wchar[] can not be concatenated @@ -269,10 +269,7 @@ bool CopyPasteManager::ExpressionRegExMatch(vector operands, ViewMode m bool expMatched = true; vector patterns{}; - // Could this be auto? - pair operandLimits = GetMaxOperandLengthAndValue(mode, modeType, programmerNumberBase, bitLengthType); - size_t maxOperandLength = operandLimits.first; - uint64_t maxOperandValue = operandLimits.second; + const auto [maxOperandLength, maxOperandValue] = GetMaxOperandLengthAndValue(mode, modeType, programmerNumberBase, bitLengthType); if (mode == ViewMode::Standard) { @@ -442,15 +439,11 @@ bool CopyPasteManager::TryOperandToULL(const wstring& operand, int numberBase, u result = stoull(operand, &size, intBase); return true; } - catch (invalid_argument) + catch (const invalid_argument&) { // Do nothing } - catch (out_of_range) - { - // Do nothing - } - catch(...) + catch (const out_of_range&) { // Do nothing }