From 3ec5e06dff7afae1b36694bc0f022b97ef42e0c2 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 15 Mar 2017 21:02:23 +0100 Subject: [PATCH] Use wxSwap() function to swap values of variables --- src/stc/gen_iface.py | 12 +++--------- src/stc/stc.cpp | 16 ++++------------ src/stc/stc.cpp.in | 4 +--- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 080de65494..50330d51f6 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -150,9 +150,7 @@ methodOverrideMap = { '''wxMemoryBuffer %s(int startPos, int endPos) { wxMemoryBuffer buf; if (endPos < startPos) { - int temp = startPos; - startPos = endPos; - endPos = temp; + wxSwap(startPos, endPos); } int len = endPos - startPos; if (!len) return buf; @@ -615,9 +613,7 @@ methodOverrideMap = { Sci_RangeToFormat fr; if (endPos < startPos) { - int temp = startPos; - startPos = endPos; - endPos = temp; + wxSwap(startPos, endPos); } fr.hdc = draw; fr.hdcTarget = target; @@ -676,9 +672,7 @@ methodOverrideMap = { '''wxString %s(int startPos, int endPos) { if (endPos < startPos) { - int temp = startPos; - startPos = endPos; - endPos = temp; + wxSwap(startPos, endPos); } int len = endPos - startPos; if (!len) return wxEmptyString; diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 9ee16d37c7..39d97943e6 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -369,9 +369,7 @@ void wxStyledTextCtrl::SetSavePoint() wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) { wxMemoryBuffer buf; if (endPos < startPos) { - int temp = startPos; - startPos = endPos; - endPos = temp; + wxSwap(startPos, endPos); } int len = endPos - startPos; if (!len) return buf; @@ -1728,9 +1726,7 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos, const wxString& text, Sci_RangeToFormat fr; if (endPos < startPos) { - int temp = startPos; - startPos = endPos; - endPos = temp; + wxSwap(startPos, endPos); } fr.hdc = draw; fr.hdcTarget = target; @@ -1819,9 +1815,7 @@ wxString wxStyledTextCtrl::GetSelectedText() { // Retrieve a range of text. wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) { if (endPos < startPos) { - int temp = startPos; - startPos = endPos; - endPos = temp; + wxSwap(startPos, endPos); } int len = endPos - startPos; if (!len) return wxEmptyString; @@ -5159,9 +5153,7 @@ wxCharBuffer wxStyledTextCtrl::GetTargetTextRaw() wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos) { if (endPos < startPos) { - int temp = startPos; - startPos = endPos; - endPos = temp; + wxSwap(startPos, endPos); } int len = endPos - startPos; if (!len) { diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 42c3a6ccb2..b18f20f669 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -624,9 +624,7 @@ wxCharBuffer wxStyledTextCtrl::GetTargetTextRaw() wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos) { if (endPos < startPos) { - int temp = startPos; - startPos = endPos; - endPos = temp; + wxSwap(startPos, endPos); } int len = endPos - startPos; if (!len) {