From ccebd10bc4bea1e65b606a054db3f98ab07850cf Mon Sep 17 00:00:00 2001 From: AmandaQuaresmaCoutinho Date: Thu, 4 Apr 2024 19:46:32 +0200 Subject: [PATCH] tdf#148251 Use std::swap instead of using temporary values Change-Id: I7629d86b8f85a493bd3ad6b9c465a81c746b1dab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165802 Tested-by: Jenkins Tested-by: Ilmari Lauhakangas Reviewed-by: Ilmari Lauhakangas --- embedserv/source/embed/tracker.cxx | 15 +++------- .../test/ole/AxTestComponents/Basic.cpp | 28 +++++-------------- 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/embedserv/source/embed/tracker.cxx b/embedserv/source/embed/tracker.cxx index 2a502671bb63..fb331dfa1478 100644 --- a/embedserv/source/embed/tracker.cxx +++ b/embedserv/source/embed/tracker.cxx @@ -201,17 +201,10 @@ void winwrap::TransformRect(LPRECT rect,HWND pWnd,HWND pWndClipTo) static void NormalizeRect(LPRECT rp) { - if(rp->left > rp->right) { - UINT tmp = rp->left; - rp->left = rp->right; - rp->right = tmp; - } - - if(rp->top > rp->bottom) { - UINT tmp = rp->top; - rp->top = rp->bottom; - rp->bottom = tmp; - } + if(rp->left > rp->right) + std::swap(rp->left, rp->right); + if(rp->top > rp->bottom) + std::swap(rp->top, rp->bottom); } diff --git a/extensions/test/ole/AxTestComponents/Basic.cpp b/extensions/test/ole/AxTestComponents/Basic.cpp index 85fbb649f923..6195aba0a6f0 100644 --- a/extensions/test/ole/AxTestComponents/Basic.cpp +++ b/extensions/test/ole/AxTestComponents/Basic.cpp @@ -116,34 +116,26 @@ STDMETHODIMP CBasic::inObject(IDispatch *val) STDMETHODIMP CBasic::inoutBool(VARIANT_BOOL* val) { - VARIANT_BOOL aBool = *val; - *val = m_bool; - m_bool = aBool; + std::swap(*val, m_bool); return S_OK; } STDMETHODIMP CBasic::inoutByte(unsigned char* val) { - unsigned char aByte = *val; - *val = m_byte; - m_byte = aByte; + std::swap(*val, m_byte); return S_OK; } STDMETHODIMP CBasic::inoutShort(short *val) { - short aShort = *val; - *val = m_short; - m_short = aShort; + std::swap(*val, m_short); return S_OK; } STDMETHODIMP CBasic::inoutLong(long *val) { - long aLong = *val; - *val = m_long; - m_long = aLong; + std::swap(*val, m_long); return S_OK; } @@ -159,17 +151,13 @@ STDMETHODIMP CBasic::inoutString(BSTR *val) STDMETHODIMP CBasic::inoutFloat(float *val) { - float aFloat = *val; - *val = m_float; - m_float = aFloat; + std::swap(*val, m_float); return S_OK; } STDMETHODIMP CBasic::inoutDouble(double *val) { - double aDouble = *val; - *val = m_double; - m_double = aDouble; + std::swap(*val, m_double); return S_OK; } @@ -1033,9 +1021,7 @@ STDMETHODIMP CBasic::outCurrency(CY* val) STDMETHODIMP CBasic::inoutCurrency(CY* val) { - CY tmp = *val; - *val = m_cy; - m_cy = tmp; + std::swap(*val, m_cy); return S_OK; }