Stefan Teleman
2012-03-21 69c711298adee8956c50f1c2e74c76babbadac5b
7148352 performance improvement for stdcxx based on 7144618
1 files added
26 ■■■■■ changed files
components/stdcxx/patches/092-7148352-basic_ios.patch 26 ●●●●● patch | view | raw | blame | history
components/stdcxx/patches/092-7148352-basic_ios.patch
New file
@@ -0,0 +1,26 @@
# patch for 7148352
--- stdcxx-4.2.1/include/rw/_basic_ios.h    2008-04-24 17:23:43.000000000 -0700
+++ stdcxx-4.2.1/include/rw/_basic_ios.h    2012-03-08 10:57:28.262697514 -0800
@@ -217,12 +217,20 @@
     // 27.4.4.2, p10
     char narrow (char_type __c, char __dflt) const {
-        return _USE_FACET (ctype<char_type>, getloc ()).narrow (__c, __dflt);
+    // For better performance, call the non-const version of getloc
+    basic_ios<_CharT, _Traits>* p =
+        const_cast<basic_ios<_CharT, _Traits>*>(this);
+
+        return _USE_FACET (ctype<char_type>, p->getloc()).narrow (__c, __dflt);
     }
     // 27.4.4.2, p11
     char_type widen (char __c) const {
-        return _USE_FACET (ctype<char_type>, getloc ()).widen (__c);
+    // For better performance, call the non-const version of getloc
+    basic_ios<_CharT, _Traits>* p =
+        const_cast<basic_ios<_CharT, _Traits>*>(this);
+
+        return _USE_FACET (ctype<char_type>, p->getloc()).widen (__c);
     }
 protected: