This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] Speedup locale::operator==


Hi,

I committed the below, tested x86-linux.

Paolo.

/////////////
2004-04-15  Paolo Carlini  <pcarlini@suse.de>

	* src/locale.cc (locale::operator==): When _M_impl == __rhs._M_impl
	avoid constructing unnecessarily this->name().
diff -urN libstdc++-v3-orig/src/locale.cc libstdc++-v3/src/locale.cc
--- libstdc++-v3-orig/src/locale.cc	2004-02-27 01:49:49.000000000 +0100
+++ libstdc++-v3/src/locale.cc	2004-04-14 18:09:55.000000000 +0200
@@ -70,9 +70,16 @@
   bool
   locale::operator==(const locale& __rhs) const throw()
   {
-    string __name = this->name();
-    return (_M_impl == __rhs._M_impl 
-	    || (__name != "*" && __name == __rhs.name()));
+    bool __ret = false;
+    if (_M_impl == __rhs._M_impl)
+      __ret = true;
+    else
+      {
+	const string __name = this->name();
+	if (__name != "*" && __name == __rhs.name())
+	  __ret = true;
+      }
+    return __ret;
   }
 
   const locale&

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]