diff --git a/src/CalcManager/CalculatorVector.h b/src/CalcManager/CalculatorVector.h index bd82abb..4a139c8 100644 --- a/src/CalcManager/CalculatorVector.h +++ b/src/CalcManager/CalculatorVector.h @@ -16,16 +16,15 @@ class CalculatorVector public: ResultCode GetAt(_In_opt_ unsigned int index, _Out_ TType* item) { - ResultCode hr = S_OK; try { *item = m_vector.at(index); } catch (const std::out_of_range& /*ex*/) { - hr = E_BOUNDS; + return E_BOUNDS; } - return hr; + return S_OK; } ResultCode GetSize(_Out_ unsigned int* size) @@ -36,35 +35,32 @@ public: ResultCode SetAt(_In_ unsigned int index, _In_opt_ TType item) { - ResultCode hr = S_OK; try { m_vector[index] = item; } catch (const std::out_of_range& /*ex*/) { - hr = E_BOUNDS; + return E_BOUNDS; } - return hr; + return S_OK; } ResultCode RemoveAt(_In_ unsigned int index) { - ResultCode hr = S_OK; if (index < m_vector.size()) { m_vector.erase(m_vector.begin() + index); } else { - hr = E_BOUNDS; + return E_BOUNDS; } - return hr; + return S_OK; } ResultCode InsertAt(_In_ unsigned int index, _In_ TType item) { - ResultCode hr = S_OK; try { auto iter = m_vector.begin() + index; @@ -72,14 +68,13 @@ public: } catch (const std::bad_alloc& /*ex*/) { - hr = E_OUTOFMEMORY; + return E_OUTOFMEMORY; } - return hr; + return S_OK; } ResultCode Truncate(_In_ unsigned int index) { - ResultCode hr = S_OK; if (index < m_vector.size()) { auto startIter = m_vector.begin() + index; @@ -87,23 +82,22 @@ public: } else { - hr = E_BOUNDS; + return E_BOUNDS; } - return hr; + return S_OK; } ResultCode Append(_In_opt_ TType item) { - ResultCode hr = S_OK; try { m_vector.push_back(item); } catch (const std::bad_alloc& /*ex*/) { - hr = E_OUTOFMEMORY; + return E_OUTOFMEMORY; } - return hr; + return S_OK; } ResultCode RemoveAtEnd() @@ -120,12 +114,12 @@ public: ResultCode GetString(_Out_ std::wstring* expression) { - ResultCode hr = S_OK; unsigned int nTokens = 0; - std::pair currentPair; - hr = this->GetSize(&nTokens); + ResultCode hr = this->GetSize(&nTokens); if (SUCCEEDED(hr)) { + + std::pair currentPair; for (unsigned int i = 0; i < nTokens; i++) { hr = this->GetAt(i, ¤tPair);