[PPL-devel] [GIT] ppl/ppl(master): Avoid abusing sort-circuited logical operators.

Enea Zaffanella zaffanella at cs.unipr.it
Fri Feb 17 11:21:04 CET 2012


Module: ppl/ppl
Branch: master
Commit: 29d65d78b2f43ecac60f5dc0f1af0804d740acab
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=29d65d78b2f43ecac60f5dc0f1af0804d740acab

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Fri Feb 17 11:05:52 2012 +0100

Avoid abusing sort-circuited logical operators.

---

 src/Partially_Reduced_Product.templates.hh |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/Partially_Reduced_Product.templates.hh b/src/Partially_Reduced_Product.templates.hh
index d79ab8f..313ed8a 100644
--- a/src/Partially_Reduced_Product.templates.hh
+++ b/src/Partially_Reduced_Product.templates.hh
@@ -442,12 +442,17 @@ Partially_Reduced_Product<D1, D2, R>::ascii_load(std::istream& s) {
       || str.substr(1) != "reduced")
     return false;
   reduced = (str[0] == yes);
-  return ((s >> str) && str == "Domain"
-          && (s >> str) && str == "1:"
-	  && d1.ascii_load(s)
-	  && (s >> str) && str == "Domain"
-	  && (s >> str) && str == "2:"
-	  && d2.ascii_load(s));
+  if (!(s >> str) || str != "Domain")
+    return false;
+  if (!(s >> str) || str != "1:")
+    return false;
+  if (!d1.ascii_load(s))
+    return false;
+  if (!(s >> str) || str != "Domain")
+    return false;
+  if (!(s >> str) || str != "2:")
+    return false;
+  return d2.ascii_load(s);
 }
 
 template <typename D1, typename D2>




More information about the PPL-devel mailing list