From 615df85c75f62325e821b1a9bc9ec9b4294a305e Mon Sep 17 00:00:00 2001 From: Nicholas Baron Date: Mon, 25 Mar 2019 23:08:25 -0700 Subject: [PATCH] A few odds and ends Optimized one loop, added a default catch --- src/CalcViewModel/Common/CopyPasteManager.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/CalcViewModel/Common/CopyPasteManager.cpp b/src/CalcViewModel/Common/CopyPasteManager.cpp index a6ef1cb9..0a99dd16 100644 --- a/src/CalcViewModel/Common/CopyPasteManager.cpp +++ b/src/CalcViewModel/Common/CopyPasteManager.cpp @@ -429,7 +429,7 @@ bool CopyPasteManager::TryOperandToULL(const wstring& operand, int numberBase, u case BinBase: intBase = 2; break; - case DecBase: + case DecBase: // Unneeded as the default is already 10? intBase = 10; break; } @@ -448,6 +448,10 @@ bool CopyPasteManager::TryOperandToULL(const wstring& operand, int numberBase, u { // Do nothing } + catch(...) + { + // Do nothing + } return false; } @@ -472,13 +476,13 @@ size_t CopyPasteManager::OperandLength(wstring operand, ViewMode mode, CategoryG size_t CopyPasteManager::StandardScientificOperandLength(wstring operand) { + // Loop until a decimal is found or if the end is reached bool hasDecimal = false; - for (size_t i = 0; i < operand.length(); i++) + for (size_t i = 0; i < operand.length() && !hasDecimal; i++) { if (operand[i] == L'.') { hasDecimal = true; - break; } }