From 564ab31a536c90ff37fc5a4d4ffc09b55c7bdb96 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 10 May 2007 11:17:38 +0000 Subject: [PATCH] fixed wxString::Last() to run in O(1), not O(n), in UTF-8 build git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45940 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/string.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/include/wx/string.h b/include/wx/string.h index 48fbfb0484..a74b39807a 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -1045,18 +1045,17 @@ public: // get last character wxUniChar Last() const - { - wxASSERT_MSG( !empty(), _T("wxString: index out of bounds") ); - - return at(length() - 1); - } + { + wxASSERT_MSG( !empty(), _T("wxString: index out of bounds") ); + return *rbegin(); + } // get writable last character wxUniCharRef Last() - { - wxASSERT_MSG( !empty(), _T("wxString: index out of bounds") ); - return at(length() - 1); - } + { + wxASSERT_MSG( !empty(), _T("wxString: index out of bounds") ); + return *rbegin(); + } /* Note that we we must define all of the overloads below to avoid -- 2.50.0