]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed wxString::Last() to run in O(1), not O(n), in UTF-8 build
authorVáclav Slavík <vslavik@fastmail.fm>
Thu, 10 May 2007 11:17:38 +0000 (11:17 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Thu, 10 May 2007 11:17:38 +0000 (11:17 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45940 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/string.h

index 48fbfb04840cd88af0ef27543c0ded1085f25f4b..a74b39807a01d841cef954cfb94458b1047e2d15 100644 (file)
@@ -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