← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba

 

Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.

Requested reviews:
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/116894

1. Tweaked equals().
2. Added "const" to std_string function arguments.
-- 
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/116894
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/util/string/rep_base.h'
--- src/util/string/rep_base.h	2012-07-24 08:48:48 +0000
+++ src/util/string/rep_base.h	2012-07-26 15:41:42 +0000
@@ -197,8 +197,10 @@
   }
 
   /**
-   * Checks whether this representation is shared.
+   * Checks if the given shared-count indicates whether some string's
+   * representation is shared.
    *
+   * @param count The shared-count to check.
    * @return Returns \c true only if it is.
    */
   static bool is_shared( count_type count ) {
@@ -206,7 +208,7 @@
   }
 
   /**
-   * Checks whether this representation is unsharable.
+   * Checks whether this representation is sharable.
    *
    * @return Returns \c true only if it is.
    */
@@ -215,8 +217,10 @@
   }
 
   /**
-   * Checks whether this representation is unsharable.
+   * Checks if the given shared-count indicates whether some string's
+   * representation is sharable.
    *
+   * @param count The shared-count to check.
    * @return Returns \c true only if it is.
    */
   static bool is_sharable( count_type count ) {

=== modified file 'src/util/string/rstring.h'
--- src/util/string/rstring.h	2012-07-24 08:48:48 +0000
+++ src/util/string/rstring.h	2012-07-26 15:41:42 +0000
@@ -2943,7 +2943,7 @@
  * @return Returns \c true only if \a s1 \c == \a s2.
  */
 inline bool equals( char const *s1, size_t s1_n, char const *s2, size_t s2_n ) {
-  return s1_n == s2_n && std::memcmp( s1, s2, s1_n ) == 0;
+  return s1_n == s2_n && (s1 == s2 || std::memcmp( s1, s2, s1_n ) == 0);
 }
 
 template<class Rep> inline bool
@@ -2957,12 +2957,14 @@
 }
 
 template<class Rep> inline bool
-operator==( rstring<Rep> const &s1, typename rstring<Rep>::std_string s2 ) {
+operator==( rstring<Rep> const &s1,
+            typename rstring<Rep>::std_string const &s2 ) {
   return equals( s1.data(), s1.size(), s2.data(), s2.size() );
 }
 
 template<class Rep> inline bool
-operator==( typename rstring<Rep>::std_string s1, rstring<Rep> const &s2 ) {
+operator==( typename rstring<Rep>::std_string const &s1,
+            rstring<Rep> const &s2 ) {
   return equals( s1.data(), s1.size(), s2.data(), s2.size() );
 }
 
@@ -2989,12 +2991,14 @@
 }
 
 template<class Rep> inline bool
-operator!=( rstring<Rep> const &s1, typename rstring<Rep>::std_string s2 ) {
+operator!=( rstring<Rep> const &s1,
+            typename rstring<Rep>::std_string const &s2 ) {
   return !(s1 == s2);
 }
 
 template<class Rep> inline bool
-operator!=( typename rstring<Rep>::std_string s1, rstring<Rep> const &s2 ) {
+operator!=( typename rstring<Rep>::std_string const &s1,
+            rstring<Rep> const &s2 ) {
   return !(s1 == s2);
 }
 
@@ -3019,12 +3023,14 @@
 }
 
 template<class Rep> inline bool
-operator<( rstring<Rep> const &s1, typename rstring<Rep>::std_string s2 ) {
+operator<( rstring<Rep> const &s1,
+           typename rstring<Rep>::std_string const &s2 ) {
   return s1.compare( s2 ) < 0;
 }
 
 template<class Rep> inline bool
-operator<( typename rstring<Rep>::std_string s1, rstring<Rep> const &s2 ) {
+operator<( typename rstring<Rep>::std_string const &s1,
+           rstring<Rep> const &s2 ) {
   return s2.compare( s1 ) > 0;
 }
 
@@ -3049,12 +3055,14 @@
 }
 
 template<class Rep> inline bool
-operator<=( rstring<Rep> const &s1, typename rstring<Rep>::std_string s2 ) {
+operator<=( rstring<Rep> const &s1,
+            typename rstring<Rep>::std_string const &s2 ) {
   return s1.compare( s2 ) <= 0;
 }
 
 template<class Rep> inline bool
-operator<=( typename rstring<Rep>::std_string s1, rstring<Rep> const &s2 ) {
+operator<=( typename rstring<Rep>::std_string const &s1,
+            rstring<Rep> const &s2 ) {
   return s2.compare( s1 ) >= 0;
 }
 
@@ -3079,12 +3087,14 @@
 }
 
 template<class Rep> inline bool
-operator>( rstring<Rep> const &s1, typename rstring<Rep>::std_string s2 ) {
+operator>( rstring<Rep> const &s1,
+           typename rstring<Rep>::std_string const &s2 ) {
   return s1.compare( s2 ) > 0;
 }
 
 template<class Rep> inline bool
-operator>( typename rstring<Rep>::std_string s1, rstring<Rep> const &s2 ) {
+operator>( typename rstring<Rep>::std_string const &s1,
+           rstring<Rep> const &s2 ) {
   return s2.compare( s1 ) < 0;
 }
 
@@ -3109,12 +3119,14 @@
 }
 
 template<class Rep> inline bool
-operator>=( rstring<Rep> const &s1, typename rstring<Rep>::std_string s2 ) {
+operator>=( rstring<Rep> const &s1,
+            typename rstring<Rep>::std_string const &s2 ) {
   return s1.compare( s2 ) >= 0;
 }
 
 template<class Rep> inline bool
-operator>=( typename rstring<Rep>::std_string s1, rstring<Rep> const &s2 ) {
+operator>=( typename rstring<Rep>::std_string const &s1,
+            rstring<Rep> const &s2 ) {
   return s2.compare( s1 ) <= 0;
 }
 


Follow ups